Buy digital products from your own system
Query the live catalog, pay from your USDT balance and get the delivery in the same response. One REST API plus webhook events.
curl -X POST https://api.hegodigitaldev.com/api/v1/buyer/orders \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-H "Idempotency-Key: 7f9c2e0a-51d4-4c1b-9a67-3e0d2b8a11f4" \
-H "Content-Type: application/json" \
-d '{"productId": 102, "quantity": 2, "expectedPriceUsdt": 7}'import { randomUUID } from 'node:crypto';
const idempotencyKey = randomUUID(); // store it BEFORE sending
const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders', {
method: 'POST',
headers: {
'X-API-Key': process.env.HEGO_API_KEY,
'Idempotency-Key': idempotencyKey,
'Content-Type': 'application/json',
},
body: JSON.stringify({ productId: 102, quantity: 2, expectedPriceUsdt: 7 }),
});
const order = await res.json();
if (res.status === 201) {
console.log(order.orderId, order.status, order.delivery?.items);
} else {
console.error(order.error, order.message);
}import os, uuid, requests
idempotency_key = str(uuid.uuid4()) # store it BEFORE sending
res = requests.post(
'https://api.hegodigitaldev.com/api/v1/buyer/orders',
headers={
'X-API-Key': os.environ['HEGO_API_KEY'],
'Idempotency-Key': idempotency_key,
},
json={'productId': 102, 'quantity': 2, 'expectedPriceUsdt': 7},
timeout=30,
)
order = res.json()
if res.status_code == 201:
print(order['orderId'], order['status'], order.get('delivery'))
else:
print(order['error'], order['message']){
"success": true,
"orderId": 45012,
"status": "completed",
"productId": 102,
"quantity": 2,
"totalPriceUsdt": 7,
"createdAt": 1767225600000,
"delivery": {
"items": [
"maria.lopez@example.com:Pass#8842",
"juan.perez@example.com:Pass#1937"
]
},
"balanceAfterUsdt": 143.25,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Quickstart#
Five steps take you from zero to your first automated purchase.
Generate your API key
In the Telegram bot open Profile → Developer API → Generate and accept the terms. The key starts with
hg_live_and is shown only once: store it in a secret manager.You can have one active key. You can generate it even before topping up.
Top up your wallet
API purchases are charged to your USDT wallet, the same one you use in the bot. Top up from the wallet section of the bot and check the balance:
curl https://api.hegodigitaldev.com/api/v1/buyer/balance \ -H "X-API-Key: hg_live_YOUR_API_KEY"const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/balance', { headers: { 'X-API-Key': process.env.HEGO_API_KEY }, }); const { balanceUsdt } = await res.json(); console.log(`Balance: ${balanceUsdt} USDT`);import os, requests res = requests.get( 'https://api.hegodigitaldev.com/api/v1/buyer/balance', headers={'X-API-Key': os.environ['HEGO_API_KEY']}, timeout=15, ) print(res.json()['balanceUsdt'])200 OKResponse{ "success": true, "balanceUsdt": 143.25, "requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30" }Read the catalog
Pick an
idand note itspriceUsdt. IfrequiresRecipientistrue, you will need the Telegram user who will receive the product.To test: buy the TEST ITEM product, made to verify your integration without spending on a real product. The prices you see already include the API client discount when one is active.
curl https://api.hegodigitaldev.com/api/v1/buyer/products \ -H "X-API-Key: hg_live_YOUR_API_KEY"const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/products', { headers: { 'X-API-Key': process.env.HEGO_API_KEY }, }); const { products } = await res.json(); for (const p of products) { console.log(p.id, p.name, p.priceUsdt, p.availableStock); }import os, requests res = requests.get( 'https://api.hegodigitaldev.com/api/v1/buyer/products', headers={'X-API-Key': os.environ['HEGO_API_KEY']}, timeout=15, ) for p in res.json()['products']: print(p['id'], p['name'], p['priceUsdt'], p['availableStock'])200 OKResponse{ "success": true, "products": [ { "id": 102, "name": "Netflix 1 Screen (30 days)", "description": "Single profile with PIN. Renewable.", "instructions": "Sign in with the email and password delivered. Do not change the password.", "priceUsdt": 3.5, "quantityTiers": [ { "quantity": 5, "totalPriceUsdt": 15 } ], "availableStock": 18, "requiresRecipient": false }, { "id": 215, "name": "Telegram Premium 3 months", "description": "Direct activation on the account you specify.", "instructions": "", "priceUsdt": 14.9, "quantityTiers": [], "availableStock": "unlimited", "requiresRecipient": true } ], "requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30" }Make your first purchase
Send
productId,quantityand the total price you expect to pay. Generate a newIdempotency-Key(a UUID) for every purchase and store it before sending.curl -X POST https://api.hegodigitaldev.com/api/v1/buyer/orders \ -H "X-API-Key: hg_live_YOUR_API_KEY" \ -H "Idempotency-Key: 7f9c2e0a-51d4-4c1b-9a67-3e0d2b8a11f4" \ -H "Content-Type: application/json" \ -d '{"productId": 102, "quantity": 2, "expectedPriceUsdt": 7}'import { randomUUID } from 'node:crypto'; const idempotencyKey = randomUUID(); // store it BEFORE sending const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders', { method: 'POST', headers: { 'X-API-Key': process.env.HEGO_API_KEY, 'Idempotency-Key': idempotencyKey, 'Content-Type': 'application/json', }, body: JSON.stringify({ productId: 102, quantity: 2, expectedPriceUsdt: 7 }), }); const order = await res.json(); if (res.status === 201) { console.log(order.orderId, order.status, order.delivery?.items); } else { console.error(order.error, order.message); }import os, uuid, requests idempotency_key = str(uuid.uuid4()) # store it BEFORE sending res = requests.post( 'https://api.hegodigitaldev.com/api/v1/buyer/orders', headers={ 'X-API-Key': os.environ['HEGO_API_KEY'], 'Idempotency-Key': idempotency_key, }, json={'productId': 102, 'quantity': 2, 'expectedPriceUsdt': 7}, timeout=30, ) order = res.json() if res.status_code == 201: print(order['orderId'], order['status'], order.get('delivery')) else: print(order['error'], order['message'])201 CreatedResponse{ "success": true, "orderId": 45012, "status": "completed", "productId": 102, "quantity": 2, "totalPriceUsdt": 7, "createdAt": 1767225600000, "delivery": { "items": [ "maria.lopez@example.com:Pass#8842", "juan.perez@example.com:Pass#1937" ] }, "balanceAfterUsdt": 143.25, "requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30" }You are doneThe delivery is in
delivery.items. You also get a copy in your Telegram chat.Receive events (recommended)
Set up a webhook to learn about price and stock changes, asynchronous deliveries and low balance without polling. See Webhooks.
Every purchase uses real balance. To practice without spending, use /health, /products and /balance, simulate webhooks with your own signature (see Verify the signature) and make your first purchase with the cheapest product.
Response format#
Every response is JSON in UTF-8, except file downloads. Every response includes:
| Field | Type | Description |
|---|---|---|
success | boolean | true if the operation succeeded, false for an error. |
requestId | string | Unique request identifier. Also sent in the X-Request-Id header. Log it and send it to support if something fails. |
error, message | string | Errors only: a stable code (INSUFFICIENT_BALANCE) and a readable text. Build your logic on error, not message. |
Conventions
- Amounts: always USDT, as a JSON number (
3.5, not"3.50"). Prices have up to 2 decimals. - Dates:
createdAtis an integer in Unix milliseconds (UTC). - IDs:
orderIdandproductIdare integers. - No caching: responses carry
Cache-Control: no-store. - Ignore fields you do not know: we may add new fields without notice (we will never remove or change existing ones within
/v1).
Authentication & scopes#
Send your API key on every request (except /health) using either header:
X-API-Key: hg_live_YOUR_API_KEY
# or, equivalently
Authorization: Bearer hg_live_YOUR_API_KEYEach key carries scopes. New keys include all of them:
| Scope | Allows |
|---|---|
catalog:read | GET /products |
balance:read | GET /balance |
orders:write | POST /orders (spend balance) |
orders:read | GET /orders/{id} and GET /orders/{id}/download |
webhooks:read | GET /webhook |
webhooks:write | POST /webhook, DELETE /webhook |
otp:read | POST /orders/{id}/otp (read codes of bought accounts) |
- 401
UNAUTHORIZED— the key is missing, invalid, regenerated or disabled. - 403
FORBIDDEN— the key is valid but lacks the required scope (Missing orders:write scope).
{
"success": false,
"error": "UNAUTHORIZED",
"message": "Invalid or missing API key",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Whoever holds the key can buy with your wallet. Keep it on your server only (environment variables or a secret manager), never in browser code, mobile apps, repositories or screenshots. If it leaks, regenerate it in the bot: the old one stops working immediately.
Products & delivery#
The catalog is live: prices, descriptions and stock change in real time. Each product is delivered in one of these ways:
Instant items
Credentials, links, codes or PINs. They arrive in delivery.items (a list of strings) in the purchase response itself.
File
The response carries delivery.downloadUrl. Download it with your key from GET /orders/{id}/download.
Asynchronous delivery
Some products are delivered by an external supplier with a delay. The purchase answers pending_delivery (already paid) and delivery arrives later: by webhook or by polling the order.
With recipient
Products like Telegram Premium activate on someone else's account. They require recipient.username. See the guide.
Price and stock
priceUsdtis the per-unit price. If the product hasquantityTiers(pack prices), buying exactly that quantity costs the total shown: for example 5 units for 12 USDT. Any other quantity pays, for every unit, the per-unit price of the biggest pack it reaches: with the 5-pack at 12 USDT, 6 units cost 6 × 2.40 = 14.40 USDT. Below every pack it costspriceUsdt × quantity.availableStockis a number, or"unlimited"for products with no cap. For external-supplier products it is an approximate figure refreshed periodically: if it runs out first, the purchase answersOUT_OF_STOCKorPURCHASE_FAILED.- Stock is reserved atomically per purchase: two simultaneous purchases never receive the same item.
- Held balance: while a purchase from an external supplier is in progress (normally an instant), the amount is held and your available balance in
GET /balancedrops. It is charged for good when the purchase completes and released automatically if it fails. - Only active products are listed.
Order statuses#
| Status | Meaning | What to do |
|---|---|---|
completed | Paid and delivered. delivery is available. | Hand the product to your customer. |
pending_delivery | Paid; the supplier is still delivering. | Wait for the order.completed webhook or poll GET /orders/{id} every 5–10 s. |
failed | The supplier could not deliver. The amount is refunded to your balance. | Tell your customer or retry with a new key. The order.failed webhook is sent. |
processing | Order in progress (for example, a payment-pending order created from the bot). | Check again later. |
GET /orders/{id} returns any order on your account, including those you placed from the Telegram bot.
Idempotency & retries#
Networks fail: a request can arrive while its response is lost. So that retrying never buys twice, POST /orders requires the Idempotency-Key header.
One key per purchase
Generate one UUID per purchase you intend to make and store it before sending. Maximum 128 characters.
Same attempt, same key
After a timeout or network error, resend the identical request with the same key. You will get the order that was already created, or it will be bought exactly once.
New purchase, new key
Reusing a key with a different body returns 409 IDEMPOTENCY_CONFLICT. Keys belong to your account: they keep working even if you regenerate your API key.
What is replayed and what is not
| Outcome | With the same key | Next step |
|---|---|---|
Successful purchase (201) | Returns the same order and delivery, without charging again. | Done. |
INSUFFICIENT_BALANCE, PRICE_CHANGED, NOT_FOUND | Replays the same response. | Fix it (top up, refresh the price) and use a new key. |
OUT_OF_STOCK | Not stored: it is attempted again. | You can retry with the same key once stock is back. |
502 PURCHASE_FAILED | Your balance was not debited. With own stock it is retried; with an external supplier it replays the error. | Retry; if it persists, use a new key or contact support with the requestId. |
504 PROVIDER_TIMEOUT | Your balance was not debited. Replays the same result: the supplier may have processed the purchase without us knowing. | Wait a few seconds and retry with a new key. |
409 IDEMPOTENCY_UNRESOLVED | A previous attempt was interrupted before being charged. | Nothing was debited. Retry with a new key. |
If you do not know whether a purchase happened, repeat the same request with the same key. Never generate a new key to “try again” a purchase that may already have happened.
Limits & timeouts#
| Item | Value | Detail |
|---|---|---|
| Request rate | 120 per minute per API key | Exceeding it returns 429 RATE_LIMITED with a Retry-After header (seconds). Contact support if you need more. |
| Failed authentications | 20 per 5 minutes per IP | After that, attempts with an invalid key receive 429. Requests with a valid key are not affected. |
| Body size | 64 KB | Larger returns 400. |
| Idempotency-Key | up to 128 characters | Use a UUID. |
| Supplier wait | up to 15 s | Suppliers usually answer instantly. If one does not answer in time, the purchase fails with 504 PROVIDER_TIMEOUT and is not charged. |
| Recommended client timeout | 30 s for POST /orders, 15 s elsewhere | If it expires, retry with the same Idempotency-Key. |
| Webhook | 10 s to respond | See retries. |
On a 429 or 5xx, wait with exponential backoff (1 s, 2 s, 4 s…) and honor Retry-After when present.
Telegram copy#
Even when you buy through the API, the delivery also reaches your chat with the bot, identical to a regular purchase: order summary, a backup .txt file, copy-ready items and buttons for support, problem reports and “My purchases”.
It is a courtesy copy: your integration must always rely on the API response. If you blocked the bot or have no open chat, the purchase works just the same.
Endpoint reference#
Base URL: https://api.hegodigitaldev.com/api/v1/buyer. Every endpoint except /health requires your API key.
Check that the API is up
Status check for monitoring. It needs no authentication and does not use your rate limit.
curl https://api.hegodigitaldev.com/api/v1/buyer/healthconst res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/health');
console.log(await res.json());import requests
print(requests.get('https://api.hegodigitaldev.com/api/v1/buyer/health', timeout=10).json()){
"success": true,
"service": "buyer-api",
"status": "ok",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}List the catalog
Returns all active products with their price, stock and delivery details at the time of the call.
Fields of each product
| Field | Type | Description |
|---|---|---|
id | integer | Identifier you use as productId. |
name | string | Commercial name. |
description | string | What the product includes. |
instructions | string | Usage notes delivered with the purchase. May be empty. |
priceUsdt | number | Per-unit price in USDT, already including the API client discount when one is active. |
quantityTiers | array | Pack prices: {quantity, totalPriceUsdt}. Buying exactly quantity units costs totalPriceUsdt in total. Empty ([]) when the price is flat. |
availableStock | integer | "unlimited" | Units available. |
requiresRecipient | boolean | If true, POST /orders requires recipient.username. |
- 401
UNAUTHORIZED— invalid key. - 403
FORBIDDEN— missingcatalog:read.
Fetch it on start-up, then keep your copy fresh with webhooks instead of polling constantly.
curl https://api.hegodigitaldev.com/api/v1/buyer/products \
-H "X-API-Key: hg_live_YOUR_API_KEY"const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/products', {
headers: { 'X-API-Key': process.env.HEGO_API_KEY },
});
const { products } = await res.json();
for (const p of products) {
console.log(p.id, p.name, p.priceUsdt, p.availableStock);
}import os, requests
res = requests.get(
'https://api.hegodigitaldev.com/api/v1/buyer/products',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
timeout=15,
)
for p in res.json()['products']:
print(p['id'], p['name'], p['priceUsdt'], p['availableStock']){
"success": true,
"products": [
{
"id": 102,
"name": "Netflix 1 Screen (30 days)",
"description": "Single profile with PIN. Renewable.",
"instructions": "Sign in with the email and password delivered. Do not change the password.",
"priceUsdt": 3.5,
"quantityTiers": [
{
"quantity": 5,
"totalPriceUsdt": 15
}
],
"availableStock": 18,
"requiresRecipient": false
},
{
"id": 215,
"name": "Telegram Premium 3 months",
"description": "Direct activation on the account you specify.",
"instructions": "",
"priceUsdt": 14.9,
"quantityTiers": [],
"availableStock": "unlimited",
"requiresRecipient": true
}
],
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Get your balance
Available USDT balance of your wallet. It is the same balance you see in the bot.
- 401
UNAUTHORIZED— invalid key. - 403
FORBIDDEN— missingbalance:read.
Every successful purchase also returns balanceAfterUsdt, so you do not need to query it after buying.
curl https://api.hegodigitaldev.com/api/v1/buyer/balance \
-H "X-API-Key: hg_live_YOUR_API_KEY"const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/balance', {
headers: { 'X-API-Key': process.env.HEGO_API_KEY },
});
const { balanceUsdt } = await res.json();
console.log(`Balance: ${balanceUsdt} USDT`);import os, requests
res = requests.get(
'https://api.hegodigitaldev.com/api/v1/buyer/balance',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
timeout=15,
)
print(res.json()['balanceUsdt']){
"success": true,
"balanceUsdt": 143.25,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Create a purchase
Buys a product with your balance. In one step it validates the price, reserves stock, debits your wallet and delivers. It is idempotent: retrying with the same Idempotency-Key never buys twice.
Headers
| Header | Value |
|---|---|
X-API-Key required | Your API key. |
Idempotency-Key required | Unique UUID per purchase (max 128 characters). |
Content-Type required | application/json |
Body
| Field | Type | Description |
|---|---|---|
productId required | integer | Product ID (from GET /products). |
quantity optional | integer | Units, minimum 1. Default 1. |
expectedPriceUsdt required | number | The total price you expect to pay for the whole quantity, not per unit. If the current price differs, nothing is charged and you get PRICE_CHANGED. It protects your customer from price changes. |
recipient.username optional | string | Telegram user who receives the product, with @ (5–32 characters: letters, digits and _). Required when requiresRecipient is true. |
Successful response
| Field | Description |
|---|---|
orderId | Order ID. Store it: you need it to query the order. |
status | completed or pending_delivery. See statuses. |
productId, quantity | What you bought. |
totalPriceUsdt | Amount charged. |
createdAt | Unix milliseconds. |
delivery.items | List of delivered strings (only if completed and not a file). |
delivery.downloadUrl | Relative path to download the file (file products). |
balanceAfterUsdt | Remaining balance after the purchase. |
Errors
- 400
BAD_REQUEST— missingIdempotency-Key, invalid JSON or not an object, invalid fields, missingrecipient.usernameor body over 64 KB. - 402
INSUFFICIENT_BALANCE— your balance is not enough. Nothing was charged. - 404
NOT_FOUND— the product does not exist or is unavailable. - 409
PRICE_CHANGED— the price changed; the response carriescurrentPriceUsdt. - 409
OUT_OF_STOCK— not enough stock. - 409
IDEMPOTENCY_CONFLICT— that key was already used with a different body. - 409
IDEMPOTENCY_UNRESOLVED— a previous attempt was interrupted; use a new key. - 502
PURCHASE_FAILED— could not be completed; your balance was not debited. - 504
PROVIDER_TIMEOUT— the supplier did not answer within 15 s; your balance was not debited. Retry with a new key.
Treat it as a feature, not an error: show the new price (currentPriceUsdt) to your customer or apply your tolerance rule and call again with a new Idempotency-Key and the new expectedPriceUsdt.
curl -X POST https://api.hegodigitaldev.com/api/v1/buyer/orders \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-H "Idempotency-Key: 7f9c2e0a-51d4-4c1b-9a67-3e0d2b8a11f4" \
-H "Content-Type: application/json" \
-d '{"productId": 102, "quantity": 2, "expectedPriceUsdt": 7}'import { randomUUID } from 'node:crypto';
const idempotencyKey = randomUUID(); // store it BEFORE sending
const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders', {
method: 'POST',
headers: {
'X-API-Key': process.env.HEGO_API_KEY,
'Idempotency-Key': idempotencyKey,
'Content-Type': 'application/json',
},
body: JSON.stringify({ productId: 102, quantity: 2, expectedPriceUsdt: 7 }),
});
const order = await res.json();
if (res.status === 201) {
console.log(order.orderId, order.status, order.delivery?.items);
} else {
console.error(order.error, order.message);
}import os, uuid, requests
idempotency_key = str(uuid.uuid4()) # store it BEFORE sending
res = requests.post(
'https://api.hegodigitaldev.com/api/v1/buyer/orders',
headers={
'X-API-Key': os.environ['HEGO_API_KEY'],
'Idempotency-Key': idempotency_key,
},
json={'productId': 102, 'quantity': 2, 'expectedPriceUsdt': 7},
timeout=30,
)
order = res.json()
if res.status_code == 201:
print(order['orderId'], order['status'], order.get('delivery'))
else:
print(order['error'], order['message']){
"success": true,
"orderId": 45012,
"status": "completed",
"productId": 102,
"quantity": 2,
"totalPriceUsdt": 7,
"createdAt": 1767225600000,
"delivery": {
"items": [
"maria.lopez@example.com:Pass#8842",
"juan.perez@example.com:Pass#1937"
]
},
"balanceAfterUsdt": 143.25,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": true,
"orderId": 45013,
"status": "pending_delivery",
"productId": 215,
"quantity": 1,
"totalPriceUsdt": 14.9,
"createdAt": 1767225600000,
"balanceAfterUsdt": 128.35,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": true,
"orderId": 45014,
"status": "completed",
"productId": 320,
"quantity": 1,
"totalPriceUsdt": 9,
"createdAt": 1767225600000,
"delivery": {
"downloadUrl": "/api/v1/buyer/orders/45014/download"
},
"balanceAfterUsdt": 119.35,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "PRICE_CHANGED",
"message": "Price changed",
"currentPriceUsdt": 7.2,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "INSUFFICIENT_BALANCE",
"message": "Insufficient wallet balance",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "PROVIDER_TIMEOUT",
"message": "The supplier did not answer in time. Your balance was not debited.",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Get an order
Current state of an order on your account and, when completed, its delivery. Use it to resolve pending_delivery or to reconcile your records.
- 404
NOT_FOUND— the order does not exist or is not yours. - 403
FORBIDDEN— missingorders:read.
The body has the same fields as the purchase, except balanceAfterUsdt. There is no endpoint to list orders: store the orderId of every purchase.
curl https://api.hegodigitaldev.com/api/v1/buyer/orders/45012 \
-H "X-API-Key: hg_live_YOUR_API_KEY"const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders/45012', {
headers: { 'X-API-Key': process.env.HEGO_API_KEY },
});
const order = await res.json();
console.log(order.status, order.delivery);import os, requests
res = requests.get(
'https://api.hegodigitaldev.com/api/v1/buyer/orders/45012',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
timeout=15,
)
print(res.json()['status']){
"success": true,
"orderId": 45012,
"status": "completed",
"productId": 102,
"quantity": 2,
"totalPriceUsdt": 7,
"createdAt": 1767225600000,
"delivery": {
"items": [
"maria.lopez@example.com:Pass#8842",
"juan.perez@example.com:Pass#1937"
]
},
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "NOT_FOUND",
"message": "Order not found",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Download an order file
For file products. Returns the original file (not JSON) with its Content-Type and Content-Disposition: attachment. The name has no extension: use the Content-Type to decide how to store it.
- 404
NOT_FOUND— the order does not exist, is not yours or its product is not a file. - 409
DELIVERY_NOT_READY— the order is notcompletedyet. - 502 / 503
DELIVERY_UNAVAILABLE— the file could not be retrieved right now; retry in a few seconds.
curl -L https://api.hegodigitaldev.com/api/v1/buyer/orders/45014/download \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-o pedido-45014import { writeFile } from 'node:fs/promises';
const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders/45014/download', {
headers: { 'X-API-Key': process.env.HEGO_API_KEY },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
await writeFile('pedido-45014', Buffer.from(await res.arrayBuffer()));
console.log(res.headers.get('content-type'));import os, requests
res = requests.get(
'https://api.hegodigitaldev.com/api/v1/buyer/orders/45014/download',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
timeout=60,
)
res.raise_for_status()
open('pedido-45014', 'wb').write(res.content)
print(res.headers['Content-Type'])Read the OTP code of a bought account
For streaming accounts that get codes by email (Disney+, Max, Prime Video, Paramount+, Canva, Apple TV, DAZN). First request the code from the service's app or website, then call this endpoint: it reads the latest email sent to that account and returns only the code or the link.
| Field | Type | Description |
|---|---|---|
email required | string | Email of an account delivered in that order. |
action required | string | login (Disney+), change (Disney+ email change), max, max_change (Max recovery), prime, paramount, canva, canva_change, apple_tv, apple_tv_change, dazn. |
The response carries code or link (whatever the service sent) and receivedAt when known. Each product allows only some actions; the others answer OTP_NOT_ALLOWED.
- 404
NOT_FOUND— the order does not exist, is not yours or is not completed. - 403
EMAIL_NOT_IN_ORDER— that email was not delivered in that order. - 403
OTP_NOT_ALLOWED— the product does not allow that action. - 400
OTP_ACTION_NOT_SUPPORTED— unknownaction. - 404
OTP_NOT_FOUND_YET— no code has arrived yet: request it again from the service and retry in a few seconds. - 410
OTP_WINDOW_EXPIRED— the order is more than 30 days old. - 429
RATE_LIMITED— at most 10 per hour and 30 per day per order (and per email), and 20 per minute overall. HonourretryAfterSec. - 503
OTP_UNAVAILABLE— codes cannot be read right now; retry in a few seconds.
Every call that reaches the mailbox counts against the limit, even when there is no code yet. Wait 5–10 s between attempts; a request can take up to ~30 s.
curl -X POST https://api.hegodigitaldev.com/api/v1/buyer/orders/45012/otp \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "maria.lopez@example.com", "action": "login"}'const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders/45012/otp', {
method: 'POST',
headers: {
'X-API-Key': process.env.HEGO_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({ email: 'maria.lopez@example.com', action: 'login' }),
});
const data = await res.json();
if (res.ok) console.log(data.code ?? data.link);
else if (data.error === 'OTP_NOT_FOUND_YET') console.log('Not here yet: retry in a few seconds');
else console.error(data.error, data.message);import os, requests
res = requests.post(
'https://api.hegodigitaldev.com/api/v1/buyer/orders/45012/otp',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
json={'email': 'maria.lopez@example.com', 'action': 'login'},
timeout=40,
)
data = res.json()
print(data.get('code') or data.get('link') or data['error']){
"success": true,
"code": "482913",
"receivedAt": "2026-11-30T14:05:12.000Z",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": true,
"link": "https://auth.max.com/reset?token=…",
"receivedAt": "2026-11-30T14:05:12.000Z",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "OTP_NOT_FOUND_YET",
"message": "No code or link found yet. Ask the service to send it again and retry in a few seconds",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "RATE_LIMITED",
"message": "Too many OTP requests. Retry later",
"retryAfterSec": 1740,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Get your webhook
Returns the current configuration. The secret is never shown in full again: you only see its last 4 characters in secretMasked.
- 404
NOT_FOUND— no webhook is configured. - 409
WEBHOOK_SECRET_UNREADABLE— the stored secret cannot be read; register the webhook again.
curl https://api.hegodigitaldev.com/api/v1/buyer/webhook \
-H "X-API-Key: hg_live_YOUR_API_KEY"{
"success": true,
"webhook": {
"url": "https://tienda.example.com/hooks/hego",
"events": [
"order.completed",
"order.failed",
"stock.changed",
"balance.low"
],
"balanceThresholdUsdt": 20,
"secretMasked": "***5f80"
},
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Set your webhook
Registers the URL that receives events and which ones you subscribe to. There is one webhook per account: calling again replaces the configuration and generates a new secret (the old one stops working immediately).
| Field | Type | Description |
|---|---|---|
url required | string | Public https URL. No credentials, port 443 or 8443, and a domain that resolves to a public IP (no localhost or private networks). Redirects are not followed. |
events required | string[] | One or more of: order.completed, order.failed, catalog.updated, stock.changed, balance.low. |
balanceThresholdUsdt optional | number | Threshold (≥ 0) for balance.low. |
- 400
BAD_REQUEST— invalid URL or event (HTTPS URL is required,Invalid URL destination,Port not allowed,Host does not resolve,Invalid event: …).
Store it in your secret manager: you need it to verify the signature of every event.
curl -X POST https://api.hegodigitaldev.com/api/v1/buyer/webhook \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://tienda.example.com/hooks/hego",
"events": ["order.completed", "order.failed", "stock.changed", "balance.low"],
"balanceThresholdUsdt": 20
}'const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/webhook', {
method: 'POST',
headers: {
'X-API-Key': process.env.HEGO_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://tienda.example.com/hooks/hego',
events: ['order.completed', 'order.failed', 'stock.changed', 'balance.low'],
balanceThresholdUsdt: 20,
}),
});
const { webhook } = await res.json();
// The secret is only shown now: store it in your secret manager
console.log(webhook.secret);import os, requests
res = requests.post(
'https://api.hegodigitaldev.com/api/v1/buyer/webhook',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
json={
'url': 'https://tienda.example.com/hooks/hego',
'events': ['order.completed', 'order.failed', 'stock.changed', 'balance.low'],
'balanceThresholdUsdt': 20,
},
timeout=15,
)
# The secret is only shown now: store it in your secret manager
print(res.json()['webhook']['secret']){
"success": true,
"webhook": {
"url": "https://tienda.example.com/hooks/hego",
"events": [
"order.completed",
"order.failed",
"stock.changed",
"balance.low"
],
"balanceThresholdUsdt": 20,
"secret": "whsec_live_5b1e0c7a94d3f28a6e1b0d47c93f5a82e6d1074b3c9a5f80"
},
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Delete your webhook
Disables the webhook. Because it is destructive, it requires explicit confirmation in the body: {"confirm": true}. Pending events are cancelled.
- 400
BAD_REQUEST— missingconfirm: true. - 404
NOT_FOUND— no webhook is configured.
curl -X DELETE https://api.hegodigitaldev.com/api/v1/buyer/webhook \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"confirm": true}'{
"success": true,
"message": "Webhook deleted",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Webhooks#
Instead of polling the API, let Hego tell you: we send a POST with JSON to your URL when an event you subscribed to happens. Configure it with POST /webhook.
What your server receives
| Header | Content |
|---|---|
X-Hego-Event | Event type, for example order.completed. |
X-Hego-Delivery | Unique event ID (evt_…). Use it to deduplicate. |
X-Hego-Signature | Signature: t=<timestamp>,v1=<hmac>. See verification. |
X-Request-Id | Identifier of this delivery attempt, for support. |
User-Agent | HegoMarket-BuyerAPI/1.0 |
The body is JSON with the event data plus eventId and type. Both are covered by the signature, so you can trust them.
Answer with any 2xx within 10 seconds. Anything else (or a timeout) counts as a failure and is retried.
Events & payloads#
| Event | When | What to do |
|---|---|---|
order.completed | An order was delivered: after an instant purchase or when a supplier finishes an asynchronous delivery. | If it was pending_delivery, call GET /orders/{id} to read the delivery. |
order.failed | A supplier could not deliver. The amount was already refunded to your balance. | Tell your customer or retry with a new key. |
catalog.updated | A product changed: price, name, description or status. May group several products. | Re-read those products with GET /products. |
stock.changed | A product's inventory changed (restock, sale, withdrawal). May group several. | Update your local stock. |
balance.low | Your balance dropped below your threshold because of a purchase (emitted once when crossed). | Top up your wallet. |
{
"orderId": 45013,
"eventId": "evt_9f2b7c1d4a6e08355b2c9d1e7f30a4b6",
"type": "order.completed"
}{
"orderId": 45013,
"eventId": "evt_9f2b7c1d4a6e08355b2c9d1e7f30a4b6",
"type": "order.failed"
}{
"productId": 102,
"productIds": [
98,
102
],
"eventId": "evt_9f2b7c1d4a6e08355b2c9d1e7f30a4b6",
"type": "catalog.updated"
}{
"productId": 102,
"productIds": [
98,
102
],
"eventId": "evt_9f2b7c1d4a6e08355b2c9d1e7f30a4b6",
"type": "stock.changed"
}{
"balanceUsdt": 18.4,
"thresholdUsdt": 20,
"eventId": "evt_9f2b7c1d4a6e08355b2c9d1e7f30a4b6",
"type": "balance.low"
}When many products change in a row (a bulk restock, for example), catalog.updated and stock.changed are grouped into a single delivery: productIds lists all products and productId is the latest. If the API client discount changes, a catalog.updated arrives with allProducts: true and no productId: re-read the whole catalog.
Verify the signature#
Anyone can send a POST to your URL. The signature proves Hego sent it and that nobody altered the body. Always verify it before acting.
- Read
tandv1from theX-Hego-Signatureheader. - Build the signed text:
t+.+X-Hego-Delivery+.+ the exact raw body. - Compute
HMAC-SHA256with your secret (whsec_live_…) and compare it in hex withv1, in constant time. - Reject if
t(milliseconds) is more than 5 minutes away from your clock: it prevents replays of old deliveries.
import crypto from 'node:crypto';
import express from 'express';
const app = express();
const TOLERANCE_MS = 5 * 60 * 1000;
// IMPORTANT: use the RAW body (Buffer), not the already-parsed JSON
app.post('/hooks/hego', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('X-Hego-Signature') || '';
const eventId = req.get('X-Hego-Delivery') || '';
const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')));
const fresh = Math.abs(Date.now() - Number(parts.t)) <= TOLERANCE_MS;
const expected = crypto
.createHmac('sha256', process.env.HEGO_WEBHOOK_SECRET)
.update(`${parts.t}.${eventId}.${req.body.toString('utf8')}`)
.digest('hex');
const given = Buffer.from(parts.v1 || '');
const valid = given.length === expected.length &&
crypto.timingSafeEqual(given, Buffer.from(expected));
if (!fresh || !valid) return res.sendStatus(401);
const event = JSON.parse(req.body.toString('utf8'));
res.sendStatus(200); // answer fast, process afterwards
queueForProcessing(event); // deduplicate by event.eventId
});import hashlib, hmac, os, time
from flask import Flask, request, abort
app = Flask(__name__)
TOLERANCE_S = 5 * 60
@app.post('/hooks/hego')
def hego_webhook():
raw = request.get_data() # RAW body, never re-serialized
parts = dict(p.split('=', 1) for p in request.headers.get('X-Hego-Signature', '').split(','))
event_id = request.headers.get('X-Hego-Delivery', '')
fresh = abs(time.time() * 1000 - int(parts.get('t', 0))) <= TOLERANCE_S * 1000
expected = hmac.new(
os.environ['HEGO_WEBHOOK_SECRET'].encode(),
f"{parts.get('t')}.{event_id}.".encode() + raw,
hashlib.sha256,
).hexdigest()
if not fresh or not hmac.compare_digest(expected, parts.get('v1', '')):
abort(401)
event = request.get_json()
enqueue(event) # deduplicate by event["eventId"]
return '', 200If your framework parses the JSON and serializes it again, the bytes change and the signature will not match. Read the body as bytes/text before parsing it.
Test your verification
With your secret you can sign a test delivery and send it to your own endpoint:
# Simulate a signed delivery against your endpoint (handy to test your verification)
SECRET="whsec_live_..."
BODY='{"orderId":45013,"eventId":"evt_test_1","type":"order.completed"}'
TS=$(date +%s%3N)
SIG=$(printf '%s' "$TS.evt_test_1.$BODY" | openssl dgst -sha256 -hmac "$SECRET" | sed 's/^.* //')
curl -X POST https://tienda.example.com/hooks/hego \
-H "Content-Type: application/json" \
-H "X-Hego-Event: order.completed" \
-H "X-Hego-Delivery: evt_test_1" \
-H "X-Hego-Signature: t=$TS,v1=$SIG" \
-d "$BODY"Retries & ordering#
Up to 5 attempts
Immediate, then at 1 min, 5 min, 30 min and 6 h. After the fifth failure the event is dropped and support is alerted.
At least once
The same event can arrive more than once. Deduplicate by eventId (or the X-Hego-Delivery header) and make your handling idempotent.
No strict ordering
Your account's events are sent in order, but a retry can arrive after a newer one. When in doubt, query the current state through the API.
- Answer fast (
2xx) and process in the background. - We do not follow redirects: a
3xxresponse counts as a failure. Register the final URL. - Before every delivery we check again that your domain resolves to a public IP.
- If your endpoint was down for more than a few hours, reconcile with
GET /productsandGET /orders/{id}.
Error codes#
Every error shares the same format and a stable error code you can build on.
| Code | HTTP | When it happens | What to do |
|---|---|---|---|
BAD_REQUEST | 400 | Malformed request or invalid fields. | Fix the request; do not retry as is. |
UNAUTHORIZED | 401 | API key missing, invalid or revoked. | Check the key; regenerate it if it leaked. |
INSUFFICIENT_BALANCE | 402 | Insufficient balance. | Top up and retry with a new key. |
FORBIDDEN | 403 | The key lacks the required scope. | Use a key with that scope. |
NOT_FOUND | 404 | Unknown product, order, webhook or route. | Check the ID. |
PRICE_CHANGED | 409 | The current total price does not match expectedPriceUsdt. | Use currentPriceUsdt with a new key. |
OUT_OF_STOCK | 409 | Insufficient stock. | Retry later (same key) or reduce the quantity. |
IDEMPOTENCY_CONFLICT | 409 | The key was already used with a different body. | Use a new key for a different purchase. |
IDEMPOTENCY_UNRESOLVED | 409 | A previous attempt was interrupted before being charged. | Retry with a new key. |
DELIVERY_NOT_READY | 409 | Download of an order that is not completed yet. | Wait for completed. |
WEBHOOK_SECRET_UNREADABLE | 409 | The stored secret cannot be read. | Register the webhook again. |
RATE_LIMITED | 429 | Too many requests. | Wait Retry-After seconds. |
INTERNAL_ERROR | 500 | Unexpected error on our side. | Retry with backoff; report the requestId if it persists. |
PURCHASE_FAILED | 502 | The purchase could not be completed (for example, the supplier failed). Your balance was not debited. | Retry; if it persists, contact support with the requestId. |
PROVIDER_TIMEOUT | 504 | The external supplier did not answer within 15 s. Your balance was not debited. | Wait a few seconds and retry with a new key. |
DELIVERY_UNAVAILABLE | 502 / 503 | The file could not be retrieved. | Retry in a few seconds. |
OTP_ACTION_NOT_SUPPORTED | 400 | Unknown OTP action. | Use one of the documented actions. |
EMAIL_NOT_IN_ORDER | 403 | The email was not delivered in that order. | Check the email and the orderId. |
OTP_NOT_ALLOWED | 403 | The product does not allow that OTP action. | Do not retry; contact support if you think it is a mistake. |
OTP_NOT_FOUND_YET | 404 | No code or link has arrived yet. | Request it again from the service and retry in 5–10 s. |
OTP_WINDOW_EXPIRED | 410 | The order is more than 30 days old. | Contact support. |
OTP_UNAVAILABLE | 503 | Codes cannot be read right now. | Retry in a few seconds. |
{
"success": false,
"error": "INSUFFICIENT_BALANCE",
"message": "Insufficient wallet balance",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "OUT_OF_STOCK",
"message": "Insufficient stock",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "RATE_LIMITED",
"message": "Rate limit exceeded",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}{
"success": false,
"error": "BAD_REQUEST",
"message": "Invalid order payload",
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}Robust purchase flow#
A complete Node.js example combining the essentials: one Idempotency-Key per purchase, safe retries with the same key, 429/5xx handling and waiting for asynchronous deliveries.
import { randomUUID } from 'node:crypto';
const BASE = 'https://api.hegodigitaldev.com/api/v1/buyer';
const headers = (extra = {}) => ({ 'X-API-Key': process.env.HEGO_API_KEY, ...extra });
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
// 1) Purchase with safe retries: SAME key while it is the same attempt
async function buy({ productId, quantity, expectedPriceUsdt, recipient }) {
const idempotencyKey = randomUUID(); // persist it in your database before calling
const body = JSON.stringify({ productId, quantity, expectedPriceUsdt, recipient });
for (let attempt = 1; attempt <= 4; attempt++) {
try {
const res = await fetch(`${BASE}/orders`, {
method: 'POST',
headers: headers({ 'Idempotency-Key': idempotencyKey, 'Content-Type': 'application/json' }),
body,
signal: AbortSignal.timeout(30_000), // the server waits up to 15 s for the supplier
});
const data = await res.json();
if (res.status === 201) return data;
if (res.status === 504) throw Object.assign(new Error(data.message), { code: data.error, data }); // slow supplier: nothing charged; retry later with a NEW key
if (res.status === 429) { await sleep(Number(res.headers.get('retry-after') || 1) * 1000); continue; }
if (res.status >= 500 || res.status === 409 && data.error === 'OUT_OF_STOCK') { await sleep(2 ** attempt * 500); continue; }
throw Object.assign(new Error(data.message), { code: data.error, data }); // 402, 400, 404, price 409: do not retry
} catch (err) {
if (err.code) throw err; // business error: bubble up
await sleep(2 ** attempt * 500); // timeout/network: retry with the SAME key
}
}
throw new Error('Could not confirm the purchase');
}
// 2) If it is pending_delivery, wait for the webhook or poll the order
async function waitForDelivery(orderId, { every = 5000, timeout = 600_000 } = {}) {
const deadline = Date.now() + timeout;
while (Date.now() < deadline) {
const res = await fetch(`${BASE}/orders/${orderId}`, { headers: headers() });
const order = await res.json();
if (order.status === 'completed' || order.status === 'failed') return order;
await sleep(every);
}
throw new Error('Delivery still pending');
}
// 3) Usage
const order = await buy({ productId: 215, quantity: 1, expectedPriceUsdt: 14.9, recipient: { username: '@cliente_final' } });
const final = order.status === 'pending_delivery' ? await waitForDelivery(order.orderId) : order;
console.log(final.status, final.delivery);Why it works this way
- The key is created once per purchase and reused across retries: if the response was lost, you get the same order.
- Business errors (
402,400,404, price) are not retried: repeating them does not fix them. - Store the
orderIdand outcome in your database as part of the same operation that hands the product to your customer.
Keeping your catalog in sync#
Prices and stock change all the time. The recommended pattern:
- On start-up, load everything with
GET /productsand store it. - Subscribe to
catalog.updatedandstock.changed. - When an event arrives, re-read the catalog (or only the listed
productIds) and update your copy. - As a safety net, refresh the whole catalog every 10–15 minutes.
- Always send
expectedPriceUsdt: if your copy went stale, the API protects you withPRICE_CHANGED.
Recipient products#
Products with requiresRecipient: true (for example Telegram Premium or Stars) are activated directly on a Telegram account. Say who receives it in recipient.username:
curl -X POST https://api.hegodigitaldev.com/api/v1/buyer/orders \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-H "Idempotency-Key: 0c5d7a2e-93b1-4f68-8e0a-6d41b7c9e2f5" \
-H "Content-Type: application/json" \
-d '{"productId": 215, "quantity": 1, "expectedPriceUsdt": 14.9,
"recipient": {"username": "@cliente_final"}}'{
"success": true,
"orderId": 45013,
"status": "pending_delivery",
"productId": 215,
"quantity": 1,
"totalPriceUsdt": 14.9,
"createdAt": 1767225600000,
"balanceAfterUsdt": 128.35,
"requestId": "3f0c6a52-8d1b-4a0e-9c47-2b5e7d9a1c30"
}- The username must start with
@and be 5–32 characters (letters, digits or_). - Verify the username before buying: an activation on the wrong account cannot be undone.
- If you forget the recipient you get
400 BAD_REQUESTand nothing is charged.
File products#
When the product is a file, the purchase returns delivery.downloadUrl (a relative path). Download it with your API key:
curl -L https://api.hegodigitaldev.com/api/v1/buyer/orders/45014/download \
-H "X-API-Key: hg_live_YOUR_API_KEY" \
-o pedido-45014import { writeFile } from 'node:fs/promises';
const res = await fetch('https://api.hegodigitaldev.com/api/v1/buyer/orders/45014/download', {
headers: { 'X-API-Key': process.env.HEGO_API_KEY },
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
await writeFile('pedido-45014', Buffer.from(await res.arrayBuffer()));
console.log(res.headers.get('content-type'));import os, requests
res = requests.get(
'https://api.hegodigitaldev.com/api/v1/buyer/orders/45014/download',
headers={'X-API-Key': os.environ['HEGO_API_KEY']},
timeout=60,
)
res.raise_for_status()
open('pedido-45014', 'wb').write(res.content)
print(res.headers['Content-Type'])You can download it again whenever you like while the order exists. Save the file in your own storage: your customer should never use your API key to download it.
Production checklist#
Security
Key in a secret manager · never in frontend · always HTTPS · regenerate if leaked · webhook secret stored separately.
Purchases
UUID stored before sending · same key on retries · always expectedPriceUsdt · 30 s timeout · store orderId.
Webhooks
Signature and timestamp verified · raw body · fast 2xx · dedupe by eventId · asynchronous processing.
Operations
Log the requestId · exponential backoff on 429/5xx · alert on balance.low · periodic reconciliation.
Frequently asked questions#
Is there a sandbox?
There is no separate environment: purchases use real balance. To test your integration end to end, buy the TEST ITEM product from the catalog: it is a test product made for that. You can also try /health, /products and /balance and simulate signed webhooks with your secret.
Can I buy more than 10 units in one order?
It depends on the product. Some (those delivered instantly from an external supplier) accept at most 10 units per order: with more, the API answers 400 BAD_REQUEST without charging. Split the purchase into several orders, each with its own Idempotency-Key.
Is there a discount for API clients?
There may be. When it is active, GET /products already returns the prices with the discount applied (priceUsdt and quantityTiers) and that is what is charged: use those values in expectedPriceUsdt. Some supplier products may keep their normal price when a discount would leave no margin. When the discount changes you receive a catalog.updated with allProducts: true.
My request timed out. Was I charged?
Repeat the same request with the same Idempotency-Key. If the purchase happened you get that order; if not, it happens exactly once. Never change the key.
I got 502 PURCHASE_FAILED.
Your balance was not debited. Retry; if it stays the same with the same key, use a new key. If it persists, contact support with the requestId.
I got 504 PROVIDER_TIMEOUT.
The supplier did not answer in time and your balance was not debited (the held amount is released automatically). It is rare: wait a few seconds and retry with a new key. If it happens often with a product, let us know with the requestId.
Why did my balance drop and then come back?
While a purchase with an external supplier is being processed the amount is held so nobody else can spend it. If the purchase fails it is released; if it completes it is charged for good.
Why do I get PRICE_CHANGED if the price looks the same?
expectedPriceUsdt is the total price for the quantity, not the unit price. With quantity: 3 at 3.5 each send 10.5. If the product has quantityTiers, the exact quantity of a pack costs its own total (not unit × quantity). When in doubt, use currentPriceUsdt from the response.
How do I list my orders?
Today orders are queried by ID with GET /orders/{id}. Store each purchase's orderId in your database.
How do I rotate my API key?
In the bot: Profile → Developer API → Regenerate. The old key stops working immediately and your previous Idempotency-Keys remain valid. You can also disable the API from there.
Can I call the API from a browser?
Do not: you would expose a key that spends your balance. Always call from your server.
How many keys can I have?
One active key per account. Regenerating revokes the previous one.
Which currency does it use?
USDT, for both prices and balance.
Where do I get help?
From the bot's support button. Always include the response's requestId (or the X-Request-Id header) and the orderId if applicable.
Changelog#
| Version | Date | Changes |
|---|---|---|
v1 | 2026-11 | New POST /orders/{id}/otp and otp:read scope (added to existing keys): read the code or link of a bought account without opening the bot. |
v1 | 2026-10 | Optional discount for API clients: the prices in GET /products and what is charged already include it. When it changes, catalog.updated is sent with allProducts: true (no productId). |
v1 | 2026-10 | GET /products now includes quantityTiers: the pack prices of each product (buying exactly that quantity costs that total). |
v1 | 2026-09 | Purchases with external suppliers: 15 s maximum wait (504 PROVIDER_TIMEOUT, no charge) and the balance is held while the purchase is in progress so it cannot be spent twice. |
v1 | 2026-09 | Hardening: rate limits, strict webhook validation (public destinations, no redirects), type and eventId inside the signature, grouped events with productIds, OUT_OF_STOCK (409), IDEMPOTENCY_UNRESOLVED, recovery of interrupted purchases and a failed status consistent with the webhook. |
v1 | 2026-09 | Launch: catalog, balance, idempotent purchases, order lookup and download, and signed webhooks. |
Compatible changes (new fields, new events) are added within /v1. A breaking change would ship as /v2 with prior notice.