TopupCraft API v1
Sell our top-ups and vouchers on your own website or app. Import the catalog (products, variations, images, prices), place orders, and get status updates by webhook. Orders are paid from your TopupCraft wallet.
https://topupcraft.com/api/v1JSONBDTGet your API key from Account → API.
Authentication
Send your key in the X-API-Key header on every request (Authorization: Bearer <key> also works). Keep it on your server, never in browser or app code. Regenerating the key disables the old one immediately.
curl https://topupcraft.com/api/v1/profile \ -H "X-API-Key: sk_your_key_here"
Errors & limits
Every response has success. Errors carry a stable error.code:
{
"success": false,
"error": { "code": "insufficient_balance", "message": "Wallet balance is too low for this order." }
}
| HTTP | code | Meaning |
|---|---|---|
| 401 | unauthorized | Missing or invalid API key |
| 402 | insufficient_balance | Add money to your wallet |
| 403 | ip_not_allowed, account_on_hold, account_disabled | Account or IP not allowed |
| 404 | product_not_found, variation_not_found, order_not_found | Unknown id |
| 409 | out_of_stock, order_failed | Could not place the order (nothing charged) |
| 422 | missing_field, invalid_field, invalid_quantity | Fix the request |
| 429 | rate_limited, busy | Too many requests, see Retry-After |
| 503 | api_disabled | API temporarily off |
Rate limit: 60 requests per minute per key.
GET /profile
Your wallet balance and pricing.
{
"success": true,
"data": { "id": 15, "name": "My Shop", "email": "[email protected]",
"balance": 5230.00, "currency": "BDT", "reseller": true, "discount_percent": 5 }
}
GET /catalog
All products available to you, with variations and your price (reseller discount already applied). GET /products/{id} returns one product.
{
"success": true,
"data": [{
"id": 11,
"title": "PUBG Mobile UC",
"slug": "pubg-mobile-uc",
"type": "topup", // topup | ingame | voucher
"image": "https://.../uploads/media/11/pubg.png",
"description": "Instant delivery",
"fields": [ // what to send in "fields" when ordering
{ "key": "player_id", "label": "Player ID", "type": "text", "required": true, "placeholder": "Player ID (UID)" }
],
"variations": [
{ "id": 120, "title": "60 UC", "price": 114.00, "currency": "BDT", "available": true, "max_quantity": 1 }
]
}]
}
Only variations with available: true can be ordered. Vouchers can be ordered in quantity up to max_quantity.
POST /orders
Places an order and pays it from your wallet.
| Field | Description | |
|---|---|---|
| variation_id | required | Variation id from the catalog |
| quantity | optional | Default 1 (only vouchers allow more) |
| fields | depends | Object keyed by the product's fields[].key |
| reference | optional | Your own order id (max 100 chars), returned back to you |
Send an Idempotency-Key header (any unique string, e.g. your order id). Retrying with the same key returns the first order instead of creating a new one, so a network timeout never charges you twice.
curl -X POST https://topupcraft.com/api/v1/orders \
-H "X-API-Key: sk_your_key_here" \
-H "Idempotency-Key: shop-order-1001" \
-H "Content-Type: application/json" \
-d '{"variation_id":120,"quantity":1,"fields":{"player_id":"5123456789"},"reference":"shop-order-1001"}'
// 201 Created
{
"success": true,
"data": {
"id": 91702, "reference": "shop-order-1001",
"status": "processing", "raw_status": "auto-processing",
"product": { "id": 11, "title": "PUBG Mobile UC" },
"variation": { "id": 120, "title": "60 UC" },
"quantity": 1, "amount": 114.00, "currency": "BDT",
"fields": { "player_id": "5123456789" },
"codes": [], "message": null,
"created_at": "2026-10-30T15:40:12+06:00", "updated_at": "2026-10-30T15:40:12+06:00"
}
}
Voucher orders return the codes in codes right away when in stock.
GET /orders/{id}
{id} is our order id or your reference. GET /orders?page=1&per_page=20 lists your API orders, newest first.
Order statuses
| status | Meaning |
|---|---|
| processing | Paid, being delivered |
| completed | Delivered (codes in codes for vouchers) |
| cancelled | Cancelled; the amount is returned to your wallet |
raw_status shows our internal status for support questions.
Webhooks
Set a Webhook URL (https) in Account → API. When the status of one of your API orders changes we send:
POST https://your-site.com/webhook
X-Webhook-Event: order.updated
X-Webhook-Delivery: evt_381
X-Webhook-Signature: 6f1c...e9 (hex HMAC-SHA256 of the raw body, key = your webhook secret)
{ "id": "evt_381", "event": "order.updated", "created_at": "...", "data": { ...same as GET /orders/{id}... } }
Reply with any 2xx within 10 seconds. Failed deliveries are retried after 1 min, 5 min, 15 min and 1 hour. Use X-Webhook-Delivery to ignore duplicates, and treat the webhook as a hint: you can always confirm with GET /orders/{id}.
Verify the signature (PHP):
$body = file_get_contents('php://input');
$expected = hash_hmac('sha256', $body, 'whsec_your_secret');
if (! hash_equals($expected, $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '')) {
http_response_code(401); exit;
}
$event = json_decode($body, true);
Node.js:
const sig = crypto.createHmac('sha256', SECRET).update(rawBody).digest('hex');
if (!crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(req.get('X-Webhook-Signature') || ''))) return res.sendStatus(401);
Importing products
- Call
GET /catalogand save each product (title, type, image, description). - Save each variation with its
id; this is what you send asvariation_id. - Download
imageto your own storage if you like; the URL stays valid. - Build your checkout fields from
fieldsand send them back asfields. - Set your own selling price on top of our
price, and refresh the catalog regularly (prices and stock can change).