Inspection credits and Business access via Stripe
1 min readStripe billing for inspection-credit packs and optional Business workspace access. Purchase credits, manage Business access, open the billing portal, and retrieve balances and billing history.
| Method | Endpoint | Description |
|---|---|---|
POST | /api/user/organizations/{organizationId}/payments/checkout | Create a credit-pack or Business checkout |
GET | /api/user/organizations/{organizationId}/payments/purchases | Get organization purchase history |
GET | /api/user/organizations/{organizationId}/payments/credits | Get available inspection credits and expiring lots |
POST | /api/user/organizations/{organizationId}/payments/verify | Verify checkout completion |
GET | /api/user/organizations/{organizationId}/payments/subscription | Get the Business subscription |
PATCH | /api/user/organizations/{organizationId}/payments/subscription | Update Business member capacity or interval |
GET | /api/user/organizations/{organizationId}/payments/subscription/usage | Get active member usage |
GET | /api/user/organizations/{organizationId}/payments/portal | Create a Stripe Billing Portal session |
/api/user/organizations/{organizationId}/payments/checkoutCreate a credit-pack or Business checkout
subscription:write, organization:manage-billingcurl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/checkout" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"kind":"credits","operationId":"string","packs":1,"successUrl":"https://indexhog.com/billing/success","cancelUrl":"https://indexhog.com/billing/cancel"}'const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/checkout", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
"kind": "credits",
"operationId": "string",
"packs": 1,
"successUrl": "https://indexhog.com/billing/success",
"cancelUrl": "https://indexhog.com/billing/cancel"
}),
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
Checkout session created
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"sessionId": "string",
"url": "https://example.com"
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/purchasesGet organization purchase history
subscription:read, organization:readcurl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/purchases" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/purchases", {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
| Name | Type | Description |
|---|---|---|
offset | number | null | Number of items to skip0 |
limit | number | Number of items to return (max 100)20 |
Purchase history fetched
{
"success": true,
"status": 200,
"code": "OK",
"message": "Items fetched successfully",
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"purchasedByUserId": "550e8400-e29b-41d4-a716-446655440000",
"provider": "stripe",
"items": [
{
"productId": "retired_product_id",
"quantity": 1,
"grants": [
{
"type": "seats",
"amount": 1
}
],
"kind": "business",
"billing": "recurring"
}
],
"acquiredAt": "2024-01-15T10:30:00.000Z",
"availableAt": "2024-01-15T10:30:00.000Z",
"kind": "subscription",
"subscriptionInterval": "monthly",
"expiresAt": "2024-01-15T10:30:00.000Z",
"status": "paid",
"reversedAt": null,
"reversalReason": null,
"restoredAt": null
}
],
"meta": {
"total": 100,
"offset": 0,
"limit": 10,
"hasMore": true
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/creditsGet available inspection credits and expiring lots
subscription:read, organization:readcurl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/credits" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/credits", {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
Credit balance retrieved
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"balance": 0,
"lots": [
{
"grantId": "string",
"source": "credit_pack_purchase",
"remaining": 0,
"expiresAt": "2024-01-15T10:30:00.000Z"
}
]
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/verifyVerify checkout completion
subscription:writecurl -X POST "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/verify" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"sessionId":"string"}'const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/verify", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
"sessionId": "string"
}),
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
| Name | Type | Description |
|---|---|---|
sessionIdrequired | string |
Checkout verification result
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"status": "complete",
"customerId": "string"
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/subscriptionGet the Business subscription
subscription:read, organization:readcurl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/subscription" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/subscription", {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
Business subscription retrieved
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"status": "active",
"interval": "monthly",
"currentPeriodEnd": "2024-01-15T10:30:00.000Z",
"cancelAt": "2024-01-15T10:30:00.000Z",
"memberCap": 1
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/subscriptionUpdate Business member capacity or interval
subscription:write, organization:manage-billingcurl -X PATCH "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/subscription" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"operationId":"string","memberCap":1,"interval":"monthly"}'const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/subscription", {
method: "PATCH",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
body: JSON.stringify({
"operationId": "string",
"memberCap": 1,
"interval": "monthly"
}),
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
| Name | Type | Description |
|---|---|---|
operationIdrequired | string | |
memberCap | number | |
interval | BillingInterval |
Business subscription updated
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"status": "active",
"interval": "monthly",
"currentPeriodEnd": "2024-01-15T10:30:00.000Z",
"cancelAt": "2024-01-15T10:30:00.000Z",
"memberCap": 1
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/subscription/usageGet active member usage
subscription:read, organization:readcurl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/subscription/usage" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/subscription/usage", {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
Member usage retrieved
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"activeMembers": 0,
"projectCount": 0
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}/api/user/organizations/{organizationId}/payments/portalCreate a Stripe Billing Portal session
subscription:write, organization:manage-billingcurl -X GET "https://api.indexhog.com/api/user/organizations/{organizationId}/payments/portal" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json"const response = await fetch("https://api.indexhog.com/api/user/organizations/{organizationId}/payments/portal", {
method: "GET",
headers: {
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json",
},
});
const data = await response.json();
console.log(data);| Name | Type | Description |
|---|---|---|
organizationIdrequired | string | Organization ID550e8400-e29b-41d4-a716-446655440000 |
| Name | Type | Description |
|---|---|---|
returnUrlrequired | string |
Portal session created
{
"success": true,
"status": 200,
"code": "OK",
"message": "Operation completed successfully",
"data": {
"url": "https://example.com"
}
}401— Unauthorized - Invalid or missing authentication
{
"success": false,
"status": 401,
"code": "UNAUTHORIZED",
"message": "Authentication required"
}403— Forbidden - Insufficient permissions
{
"success": false,
"status": 403,
"code": "FORBIDDEN",
"message": "You do not have permission to perform this action"
}