Partner API · v2026-06-13

Docs that ship.

Every endpoint returns the same envelope. Numeric error codes. Token-aware pricing. OpenAPI spec at /api/public/v1/openapi.json.

01

Quickstart

Mint a staging key in API keys, then POST your first top-up:

curl -X POST https://aitopup.dev/api/public/v1/topup/send \
  -H "Authorization: Bearer ak_staging_..." \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "claude",
    "amount_cents": 1000,
    "recipient_email": "user@example.com",
    "model": "claude-sonnet-4",
    "idempotency_key": "order_12345"
  }'

The response envelope:

{
  "success": true,
  "code": 1001,
  "transaction_id": "txn_…",
  "status": "delivered",
  "timestamp": "2026-07-28T15:51:41.002Z",
  "data": {
    "voucher_code": "AITOPUP-XXXX-XXXX",
    "platform": "claude",
    "amount_cents": 1000,
    "wholesale_cost_cents": 850,
    "platform_fee_cents": 15,
    "new_balance_cents": 5400
  }
}
02

Pricing & margin

List price per platform (cents per 1M tokens). Your wholesale cost depends on your partner tier; a 1.50% platform fee is added on every /topup/send.

PlatformDefault modelInput ¢ / 1MOutput ¢ / 1M
Claudeopenai/gpt-5300¢1500¢
ChatGPTopenai/gpt-5-mini50¢200¢
Geminigoogle/gemini-3-flash-preview10¢40¢

Partner tiers

TierDiscountYour cost on $10 top-upRequirement
Standard0%$10.00Default. Pay list price.
Silver15%$8.50$250+ / mo in top-ups
Gold28%$7.20$1,500+ / mo in top-ups
Platinum40%$6.00$7,500+ / mo or contract

Token-aware estimate

curl -X POST https://aitopup.dev/api/public/v1/topup/estimate \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{ "platform": "chatgpt", "tokens_in": 250000, "tokens_out": 80000 }'
03

Endpoints

  • GET/v1/pricingList prices + your discount
  • POST/v1/topup/estimateQuote from token counts
  • POST/v1/topup/sendDeliver a top-up
  • GET/v1/topup/balanceWallet balances
  • GET/v1/topup/historyPaginated history
  • POST/v1/topup/validatePre-flight check
  • POST/v1/topup/cancelCancel pending
  • GET/v1/topup/status/{txn}Lookup by id
  • POST/v1/webhooks/registerAdd a webhook
  • GET/DELETE/v1/webhooks/{id}Read or remove
  • GET/v1/openapi.jsonFull OpenAPI 3.1 spec
04

Webhooks

Each delivery is signed with X-AiTopUp-Signature: HMAC-SHA256 over the raw body using your endpoint secret. Retries run 0s · 5s · 30s with exponential backoff. Replay any delivery from Settings → Webhooks.

  • topup.deliveredCredit sent to recipient
  • topup.failedDelivery failed — no funds moved
  • topup.cancelledPending top-up cancelled
  • balance.lowWallet below your threshold
05

Error codes

Numeric codes are stable across versions. HTTP status follows the obvious mapping (401, 402, 404, 409, 429, …).

CodeMeaning
1000Success
1001Top-up delivered
1002Top-up pending
2001Invalid or revoked API key
2002Insufficient balance / monthly cap exceeded
2003Invalid platform
2004Invalid recipient email
2005Amount out of range
2006Duplicate transaction (idempotent replay)
3001Cancelled OK
3002Cannot cancel — already delivered
3003Transaction not found
4001Rate limited
4002IP not whitelisted
5001Webhook delivery failed
5002Webhook URL invalid