Skip to main content

Billing API

Retrieve billing information and perform subscription actions such as creating a checkout session, enabling bring-your-own-key (BYOK) mode, checking usage, and purchasing credit packs.
All billing endpoints require session authentication.

Get billing info

GET /api/billing
Returns the available plans, the authenticated user’s current plan, subscription status, BYOK status, and daily usage.

Response

{
  "plans": {
    "starter": {
      "name": "Starter",
      "price": 19,
      "dailyUnits": 600,
      "features": ["1 AI Agent", "2GB RAM", "Telegram", "Basic skills"]
    },
    "pro": {
      "name": "Pro",
      "price": 39,
      "dailyUnits": 1000,
      "features": ["1 AI Agent", "4GB RAM", "All channels", "All skills", "Priority support"]
    },
    "scale": {
      "name": "Scale",
      "price": 79,
      "dailyUnits": 2500,
      "features": ["3 AI Agents", "8GB RAM", "All channels", "All skills", "Analytics"]
    }
  },
  "currentPlan": "starter",
  "subscriptionStatus": "active",
  "byokEnabled": false,
  "usage": {
    "dailyUnits": 600,
    "used": 245,
    "remaining": 355
  }
}

Response fields

FieldTypeDescription
plansobjectMap of available plans with pricing and features
currentPlanstringUser’s current plan (free, starter, pro, or scale)
subscriptionStatusstringStripe subscription status (active, inactive, etc.)
byokEnabledbooleanWhether BYOK mode is active
usage.dailyUnitsnumberDaily unit allowance for the current plan
usage.usednumberUnits used today
usage.remainingnumberUnits remaining today

Errors

CodeDescription
401Unauthorized — no valid session
500Failed to fetch billing info

Billing actions

POST /api/billing
Performs a billing action. The action field in the request body determines which operation is executed.

Create checkout session

Creates a Stripe checkout session for subscribing to a plan.

Request body

FieldTypeRequiredDescription
actionstringYesMust be create-checkout
planstringYesPlan to subscribe to: starter, pro, or scale

Response

{
  "url": "https://checkout.stripe.com/c/pay/..."
}
Redirect the user to the returned url to complete payment.

Errors

CodeDescription
400Invalid plan

Enable BYOK

Enables bring-your-own-key mode with an external AI provider. When BYOK is active, AI requests are billed directly by the provider rather than consuming platform credits.

Request body

FieldTypeRequiredDescription
actionstringYesMust be enable-byok
apiKeystringYesYour API key for the external provider
providerstringYesProvider name (for example, openai, anthropic)

Response

{
  "success": true,
  "message": "BYOK enabled with openai. You'll pay openai directly for AI usage."
}

Errors

CodeDescription
400API key and provider are required

Disable BYOK

Disables BYOK mode and reverts to platform credits.

Request body

FieldTypeRequiredDescription
actionstringYesMust be disable-byok

Response

{
  "success": true,
  "message": "BYOK disabled. Using platform credits."
}

Get usage

Returns the current day’s unit consumption.

Request body

FieldTypeRequiredDescription
actionstringYesMust be get-usage

Response

{
  "dailyUnits": 600,
  "used": 245,
  "remaining": 355,
  "resetsAt": "midnight UTC"
}

Buy credits

Purchases a credit pack.

Request body

FieldTypeRequiredDescription
actionstringYesMust be buy-credits
packstringYesPack size: 50, 200, or 500

Response

{
  "success": true,
  "credits": 15,
  "price": "$15"
}
Pack sizeCredits
505
20015
50030

Errors

CodeDescription
400Invalid pack

Common errors

These apply to all billing POST actions:
CodeDescription
400Invalid action
401Unauthorized — no valid session
500Internal error

Subscription deploy

POST /api/subscriptions/deploy
Records a subscription-to-plan mapping so the next agent deployment uses the correct resource tier. This endpoint is called by the Stripe webhook after a checkout completes.
This is a backend-only endpoint that requires bearer token (API key) authentication.

Request body

FieldTypeRequiredDescription
tierstringYesPlan tier. One of: solo, collective, label, network, underground, starter, pro, scale, enterprise, white_glove
customerIdstringConditionalCustomer identifier. Either customerId or stripeCustomerId must be provided.
stripeCustomerIdstringConditionalStripe customer ID. Either customerId or stripeCustomerId must be provided.
subscriptionIdstringNoStripe subscription ID

Response

{
  "success": true,
  "customerId": "cus_abc123",
  "subscriptionId": "sub_xyz",
  "tier": "solo",
  "resources": {
    "memory": "2g",
    "cpus": "1"
  }
}

Plan resource allocations

TierMemoryCPUsNotes
solo2 GB1
collective4 GB2
label8 GB4
network16 GB4
underground2 GB1Legacy alias
starter2 GB1Legacy alias
pro4 GB2Legacy alias
scale8 GB4Legacy alias
enterprise16 GB4Legacy alias
white_glove32 GB8Legacy alias

Errors

CodeDescription
400customerId is required (when neither customer ID field is provided)
400tier is required
400Invalid tier
401Unauthorized — missing or invalid bearer token
500Subscription activation failed