Skip to main content
SONZAI
Api

Org Billing

Get org billing profile

GET
/org/billing

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/billing"
{
  "$schema": "/api/v1/schemas/TenantBillingProfile.json",
  "billingMode": "string",
  "charPricePerMonthUsd": 0.1,
  "creditBalance": 0.1,
  "currency": "string",
  "eventPrices": {
    "property1": 0.1,
    "property2": 0.1
  },
  "freeCreditGranted": true,
  "inputTokenPricePer1KUsd": 0.1,
  "outputTokenPricePer1KUsd": 0.1,
  "outstandingUsd": 0.1,
  "postpaidLimitUsd": 0.1,
  "servicePrices": {
    "property1": 0.1,
    "property2": 0.1
  },
  "stripeCustomerId": "string",
  "tenantId": "string",
  "tokenPricePer1KUsd": 0.1,
  "updatedAt": "2019-08-24T14:15:22Z"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Create Stripe checkout session (credit top-up)

POST
/org/billing/checkout

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/org/billing/checkout" \  -H "Content-Type: application/json" \  -d '{    "amount": 0  }'
{
  "$schema": "/api/v1/schemas/OrgBillingURLBody.json",
  "url": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Create Stripe billing-portal session

POST
/org/billing/portal

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/org/billing/portal"
{
  "$schema": "/api/v1/schemas/OrgBillingURLBody.json",
  "url": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

List active characters for billing

GET
/org/characters

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Query Parameters

days?integer

Lookback window in days

Default30
Formatint64
Range1 <= value <= 365

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/characters"
{
  "$schema": "/api/v1/schemas/ActiveCharacterSummary.json",
  "billedAt": "2019-08-24T14:15:22Z",
  "charChargeUsd": 0.1,
  "highWaterMark": 0,
  "month": "string",
  "pricePerCharUsd": 0.1
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Get org enterprise contract

GET
/org/contract

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/contract"
{
  "$schema": "/api/v1/schemas/EnterpriseContract.json",
  "autoRenew": true,
  "bonusCreditsPaid": true,
  "bonusCreditsUsd": 0.1,
  "contractId": "string",
  "createdAt": "2019-08-24T14:15:22Z",
  "createdBy": "string",
  "creditPeriodLimit": 0,
  "creditPortionUsd": 0.1,
  "endDate": "2019-08-24T14:15:22Z",
  "notes": "string",
  "onetimeAmountUsd": 0.1,
  "onetimeCreditUsd": 0.1,
  "onetimeServiceUsd": 0.1,
  "paymentAmountUsd": 0.1,
  "paymentCreditUsd": 0.1,
  "paymentFrequency": "string",
  "paymentLinkUrl": "string",
  "paymentSchedule": [
    {
      "amountUsd": 0.1,
      "creditUsd": 0.1,
      "dueDate": "2019-08-24T14:15:22Z",
      "isOneTime": true,
      "paid": true,
      "period": "string",
      "serviceUsd": 0.1
    }
  ],
  "paymentServiceUsd": 0.1,
  "servicePeriodLimit": 0,
  "servicePortionUsd": 0.1,
  "startDate": "2019-08-24T14:15:22Z",
  "status": "string",
  "stripePriceId": "string",
  "stripeSubscriptionId": "string",
  "tenantId": "string",
  "totalValueUsd": 0.1,
  "updatedAt": "2019-08-24T14:15:22Z"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Subscribe tenant to an enterprise contract

POST
/org/contract/subscribe

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

contractId*string

Enterprise contract UUID to subscribe to

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/org/contract/subscribe" \  -H "Content-Type: application/json" \  -d '{    "contractId": "string"  }'
{
  "$schema": "/api/v1/schemas/OrgBillingURLBody.json",
  "url": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Context engine event usage

GET
/org/events

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Query Parameters

days?integer

Lookback window in days

Default30
Formatint64
Range1 <= value <= 365

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/events"
{
  "$schema": "/api/v1/schemas/ContextEngineEventSummary.json",
  "byType": [
    {
      "chargeUsd": 0.1,
      "count": 0,
      "eventType": "string",
      "unitPriceUsd": 0.1
    }
  ],
  "month": "string",
  "totalChargeUsd": 0.1,
  "totalEvents": 0
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Get org billing ledger

GET
/org/ledger

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Query Parameters

days?integer

Lookback window in days

Default30
Formatint64
Range1 <= value <= 365

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/ledger"
[
  {
    "amountCredits": 0.1,
    "amountUsd": 0.1,
    "createdAt": "2019-08-24T14:15:22Z",
    "createdBy": "string",
    "description": "string",
    "entryId": "string",
    "entryType": "string",
    "tenantId": "string",
    "tokens": 0,
    "trafficSource": "string"
  }
]
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Get active model pricing

GET
/org/model-pricing

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/model-pricing"
[
  {
    "inputPricePer1K": 0.1,
    "model": "string",
    "outputPricePer1K": 0.1
  }
]
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

List active service agreements

GET
/org/service-agreements

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/service-agreements"
[
  {
    "active": true,
    "amountUsd": 0.1,
    "billedAt": "2019-08-24T14:15:22Z",
    "chargeId": "string",
    "chargeType": "string",
    "createdAt": "2019-08-24T14:15:22Z",
    "createdBy": "string",
    "description": "string",
    "projectId": "string",
    "projectName": "string",
    "tenantId": "string",
    "updatedAt": "2019-08-24T14:15:22Z"
  }
]
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Get org service usage

GET
/org/service-usage

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Query Parameters

days?integer

Lookback window in days

Default30
Formatint64
Range1 <= value <= 365

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/service-usage"
{
  "$schema": "/api/v1/schemas/ServiceUsageSummary.json",
  "byOperation": [
    {
      "chargeUsd": 0.1,
      "count": 0,
      "operation": "string",
      "unitPriceUsd": 0.1
    }
  ],
  "month": "string",
  "totalChargeUsd": 0.1,
  "totalEvents": 0
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Get org usage summary

GET
/org/usage-summary

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Query Parameters

days?integer

Lookback window in days

Default30
Formatint64
Range1 <= value <= 365

Response Body

application/json

application/problem+json

curl -X GET "https://loading/api/v1/org/usage-summary"
{
  "$schema": "/api/v1/schemas/OrgUsageSummaryBody.json",
  "charPricePerMonthUsd": 0.1,
  "creditBalanceUsd": 0.1,
  "estimatedCostUsd": 0.1,
  "inputTokenPricePer1KUsd": 0.1,
  "outputTokenPricePer1KUsd": 0.1,
  "tokenPricePer1KUsd": 0.1,
  "totalCharacters": 0,
  "totalInputTokens": 0,
  "totalMessages": 0,
  "totalOutputTokens": 0,
  "totalProjects": 0,
  "totalSessions": 0,
  "totalTokens": 0
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Redeem a voucher code

POST
/org/vouchers/redeem

Authorization

bearerClerk
AuthorizationBearer <token>

Clerk session JWT from an authenticated dashboard user. Format: Bearer eyJ....

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

code*string

Voucher code to redeem

Response Body

application/json

application/problem+json

curl -X POST "https://loading/api/v1/org/vouchers/redeem" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{
  "$schema": "/api/v1/schemas/RedeemVoucherResponse.json",
  "creditAmountUsd": 0.1,
  "message": "string",
  "newBalance": 0.1,
  "voucherCode": "string"
}
{
  "$schema": "/api/v1/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [
    {
      "location": "string",
      "message": "string",
      "value": null
    }
  ],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}