Billing API

Credit balance, usage tracking, Stripe checkout, and auto-topup. Billing routes accept Bearer JWT or API key.

API-first: e2a has no dashboard UI. Use these endpoints to manage billing programmatically — check balance, top up credits, and view transactions via API.

Quick Examples

Check your balance:

curl -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.e2a.bot/v1/billing/balance

Top up credits (returns Stripe checkout URL):

curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"credit_amount": 1000}' \
  https://api.e2a.bot/v1/billing/checkout

View transaction history:

curl -H "Authorization: Bearer YOUR_API_KEY" \
  https://api.e2a.bot/v1/billing/transactions?limit=10

Billing Model

  • Infra-only billing: CPU/RAM/Disk usage. LLM tokens are NOT charged — you BYO LLM key.
  • Credits: Pre-paid balance in cents (smallest currency unit).
  • Auto-topup: Automatically add credits when balance drops below threshold.

Get Balance

GETapi.e2a.bot/v1/billing/balance

Current credit balance in cents.

Response (200)

{ "credit_balance": 84750 }   // $847.50

Create Checkout Session

POSTapi.e2a.bot/v1/billing/checkout

Create a Stripe Checkout session to add credits. Returns a redirect URL.

Request

{ "credit_amount": 1000 }     // $10.00

Response (200)

{ "url": "https://checkout.stripe.com/..." }
CodeMeaningWhen
200OKsession created
400Bad requestinvalid or below-minimum amount

List Transactions

GETapi.e2a.bot/v1/billing/transactions

Paginated billing transactions (top-ups, deductions, refunds).

Query Parameters

NameDefaultDescription
limit20Max items per page
offset0Skip items

Response (200)

{
  "transactions": [
    {
      "id": "txn_...",
      "amount": -25,
      "description": "Sandbox usage",
      "timestamp": "2026-05-01T12:00:00Z"
    },
    {
      "id": "txn_...",
      "amount": 1000,
      "description": "Credit top-up",
      "timestamp": "2026-05-01T10:00:00Z"
    }
  ]
}

Auto-Topup

Get Configuration

GETapi.e2a.bot/v1/billing/auto-topup
{
  "enabled": true,
  "threshold_amount": 100,    // trigger when balance < $1.00
  "topup_amount": 500         // add $5.00
}

Update Configuration

POSTapi.e2a.bot/v1/billing/auto-topup
{
  "enabled": true,
  "threshold_amount": 500,    // trigger when balance < $5.00
  "topup_amount": 2000        // add $20.00
}