Skip to content

Overview

Billing endpoints manage your Contox subscription, usage tracking, and credit purchases. Contox uses Stripe for payment processing.

Create checkout session

Creates a Stripe checkout session for upgrading or subscribing to a plan.

POST /api/billing/checkout

Request body

FieldTypeRequiredDescription
planIdstringYesThe plan to subscribe to
seatsnumberNoNumber of seats (for team plans)
successUrlstringNoRedirect URL after successful checkout
cancelUrlstringNoRedirect URL if checkout is cancelled

Response

json
{
  "url": "https://checkout.stripe.com/c/pay/..."
}

Redirect the user to the returned URL to complete the checkout.

Open billing portal

Creates a Stripe billing portal session for managing payment methods, viewing invoices, and updating subscriptions.

POST /api/billing/portal

Response

json
{
  "url": "https://billing.stripe.com/p/session/..."
}

Cancel subscription

Cancels the current subscription at the end of the billing period.

POST /api/billing/cancel

Response

json
{
  "status": "cancelled",
  "cancelAt": "2025-02-15T00:00:00Z"
}

The subscription remains active until the end of the current billing period.

Get usage

Retrieves current usage statistics for your account.

GET /api/billing/usage

Response

json
{
  "plan": "team",
  "period": {
    "start": "2025-01-01T00:00:00Z",
    "end": "2025-02-01T00:00:00Z"
  },
  "usage": {
    "sessions": { "used": 45, "limit": 200 },
    "events": { "used": 1250, "limit": 10000 },
    "enrichments": { "used": 32, "limit": 100 },
    "storage": { "used": 52428800, "limit": 536870912 }
  }
}

Get credits

Retrieves the current credit balance and transaction history.

GET /api/billing/credits

Response

json
{
  "balance": 5200000,
  "autoRecharge": {
    "enabled": true,
    "threshold": 500000,
    "packId": "credits_2_5m",
    "spendingLimit": 5000
  },
  "transactions": [
    {
      "id": "txn_abc123",
      "type": "purchase",
      "amount": 2500000,
      "price": 1000,
      "createdAt": "2025-01-15T10:00:00Z"
    },
    {
      "id": "txn_def456",
      "type": "usage",
      "amount": -300000,
      "description": "Enrichment - session sess_xyz",
      "createdAt": "2025-01-20T12:00:00Z"
    }
  ]
}

Credit amounts are in token units. Prices are in cents (EUR).

Purchase credits

Purchases a credit pack.

POST /api/billing/credits/purchase

Request body

FieldTypeRequiredDescription
packIdstringYesThe credit pack ID

Available packs

Pack IDTokensPrice
credits_1m1,000,0005.00 EUR
credits_2_5m2,500,00010.00 EUR
credits_7m7,000,00025.00 EUR
credits_15m15,000,00050.00 EUR

Response

json
{
  "transactionId": "txn_ghi789",
  "balance": 7700000,
  "purchased": 2500000
}

Auto-recharge

Credits can be set to auto-recharge when the balance falls below a threshold. Configure this in the dashboard under Billing > Credits. The default spending limit is 50.00 EUR per billing period. Credits never expire.

Next steps