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.
| Platform | Default model | Input ¢ / 1M | Output ¢ / 1M |
|---|---|---|---|
| Claude | openai/gpt-5 | 300¢ | 1500¢ |
| ChatGPT | openai/gpt-5-mini | 50¢ | 200¢ |
| Gemini | google/gemini-3-flash-preview | 10¢ | 40¢ |
Partner tiers
| Tier | Discount | Your cost on $10 top-up | Requirement |
|---|---|---|---|
| Standard | 0% | $10.00 | Default. Pay list price. |
| Silver | 15% | $8.50 | $250+ / mo in top-ups |
| Gold | 28% | $7.20 | $1,500+ / mo in top-ups |
| Platinum | 40% | $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.delivered— Credit sent to recipient
- topup.failed— Delivery failed — no funds moved
- topup.cancelled— Pending top-up cancelled
- balance.low— Wallet below your threshold
05
Error codes
Numeric codes are stable across versions. HTTP status follows the obvious mapping (401, 402, 404, 409, 429, …).
| Code | Meaning |
|---|---|
| 1000 | Success |
| 1001 | Top-up delivered |
| 1002 | Top-up pending |
| 2001 | Invalid or revoked API key |
| 2002 | Insufficient balance / monthly cap exceeded |
| 2003 | Invalid platform |
| 2004 | Invalid recipient email |
| 2005 | Amount out of range |
| 2006 | Duplicate transaction (idempotent replay) |
| 3001 | Cancelled OK |
| 3002 | Cannot cancel — already delivered |
| 3003 | Transaction not found |
| 4001 | Rate limited |
| 4002 | IP not whitelisted |
| 5001 | Webhook delivery failed |
| 5002 | Webhook URL invalid |