API v1 documentation
For sellers integrating OTP number rental. All responses are JSON.
API key WebhookBase URL
All calls are JSON. Every action sits under this URL.
Authorization header
Replace the example with your own key from API key.
Format
Authentication
Default limit
Quick start
Buy a number, read the code, close the order. Four steps end to end.
Get your API key
Your account already has one API key at /account/api. It is shown once, so store it safely. Send it as a Bearer token on every call.
Pick a service and a country
Read the codes from /api/v1/services and /api/v1/countries, then check price and stock with /api/v1/offers.
Create a rental
POST /api/v1/rentals with the channel, service and country. Add an Idempotency-Key so a retry never charges twice.
Read the code, then close the order
Poll GET /api/v1/rentals/{public_id} until otp_code appears, then call finish. No code in time means an automatic refund.
1Introduction & Base URL
API v1 uses JSON for both requests and responses. Every successful response has the form
{"success": true, "data": …}; every error response has the form
{"success": false, "error": {"code": …, "message": …}}.
Base URL:
This document describes only what the API actually returns. Internal fields (provider, cost price, profit, routing) never appear in responses.
2Authentication
Every endpoint requires an API key, sent in the header:
Authorization: Bearer otp_live_EXAMPLE_NOT_A_REAL_KEY
- Mỗi tài khoản có đúng một khóa API, có sẵn tại /account/api.
- The key is shown only once khi cấp (hoặc khi tạo lại). Hãy lưu ngay.
- Khóa có đầy đủ quyền của API khách (đặt/hủy/kết thúc/xin mã, xem đơn, catalog, số dư).
- Keys can be restricted by IP whitelist; calls from other IPs will be rejected.
- Muốn đổi khóa (lộ/ quên), bấm Tạo lại khóa — khóa cũ bị thu hồi ngay.
| Code | HTTP | When |
|---|---|---|
UNAUTHORIZED | 401 | Key missing, incorrect, revoked or expired. |
ACCOUNT_BANNED | 403 | The account that owns the key is locked. |
EMAIL_NOT_VERIFIED | 403 | Accounts with unverified email (when the system requires it) cannot create orders yet. |
3Rate limit
Limit counted by each API key within the window 60 seconds: default plan 60 requests/minute, premium plan 300 requests/minute. Exceeding the limit returns 429 with code rate_limited.
The API currently sends no header describing the remaining quota; space out your calls yourself when you receive 429.
{"success": false, "error": {"code": "RATE_LIMITED", "message": "Too many requests. Please slow down."}}4Endpoints
All paths below are under /api/v1. Header Authorization is required on every endpoint.
/api/v1/metaThông tin phiên bản, định danh bản cài và những năng lực đang bật. Không tham số.
{"success": true, "data": {
"protocol": "otp-aggregator",
"api_version": "v1",
"instance_id": "…",
"capabilities": {"balance": true, "catalog": true, "services": true,
"countries": true, "domains": true, "offers": true,
"pricing": true, "availability": true, "rentals": true},
"capability_list": ["sms", "email", "balance", "catalog", "cancel",
"finish", "next_code", "rentals"],
"api": {"name": "OTP Aggregator Public API", "version": "v1", "major_version": 1},
"instance": {"id": "…"},
"capability_flags": {"balance": true, "catalog": true, "services": true,
"countries": true, "domains": true, "offers": true,
"pricing": true, "availability": true, "rentals": true},
"server_time": "2026-11-10T09:14:53Z",
"supported_channels": ["sms", "email"],
"default_currency": "VND"
}}
capabilities là OBJECT cờ boolean như bản v1 đã công bố từ trước — giữ
nguyên kiểu, không đổi thành danh sách. Trong đó rentals nay là
true vì các route thuê số thật sự đang phục vụ.
capability_list là DANH SÁCH năng lực bản cài này thật sự phục vụ, đọc từ
chính các route đang chạy: sms/email (email chỉ xuất hiện khi
catalogue có offer email còn hạn), balance, catalog,
cancel, finish, next_code, rentals.
Đây là trường mà adapter liên kết (OtpAggregatorAdapter) đọc để quyết định
bật/tắt nút thao tác; adapter vẫn đọc được cả dạng danh sách cũ nếu gặp bạn liên kết
chưa nâng cấp.
capability_flags là bản sao của capabilities, giữ lại cho client
đã cấu hình trước đây; instance_id and instance.id luôn bằng nhau.
server_time is the server time in UTC, suffix Z.
/api/v1/balanceCurrent wallet balance. No parameters.
{"success": true, "data": {"balance": "250000.0000", "currency": "VND"}}/api/v1/servicesList of services. Optional query parameters: channel (sms | email).
{"success": true, "data": {"services": [
{"code": "telegram", "name": "Telegram", "channel": "sms"}
], "total": 1}}/api/v1/countriesList of countries. No parameters.
{"success": true, "data": {"countries": [
{"code": "US", "iso2": "US", "name": "United States", "dial_code": "+1"}
], "total": 1}}
dial_code can be null if that country has no dialing code yet.
total is the number of elements in countries.
/api/v1/offers
Selling price and stock per service/country. Query parameters (all optional):
channel (sms | email),
service_id (number), country_id (number).
service_id / country_id is internal numeric id of the catalog table, not a string code. Passing a non-numeric value returns 400 validation_error.
{"success": true, "data": {"offers": [
{"service_code": "telegram", "country_code": "US", "channel": "sms",
"price": "15000.0000", "currency": "VND", "available": 42}
], "total": 1}}
Filter by service_code / country_code by code string, not numeric id.
country_code can be null for offers with no country (email channel).
available is the stock aggregated across enabled routes.
Each row also carries tiers: the price levels still in stock for that service/country, cheapest first; each level has price_vnd, price_label, available and cheapest. Pass the exact price_vnd to POST /api/v1/rentals to buy that level — the amount charged is always the one you picked.
/api/v1/rentalsCreate a rental order. JSON body:
| Field | Type | Required | Note |
|---|---|---|---|
channel | string | yes | sms or email |
service_code | string | yes | code taken from /services |
country_code | string | exists with sms | ISO2 taken from /countries |
domain | string | exists with email | service domain |
price | number or string | no | The exact price_vnd of the level you picked (see tiers). Empty = cheapest level. If that level is no longer on sale, 409 PRICE_CHANGED is returned with the new levels and nothing is charged. |
Header support Idempotency-Key: send repeatedly same key + same content will get the original order back (no new order is created, no second charge). The same key with different content is rejected
409 idempotency_key_reused. A key can only be used once for one order.
curl -X POST https://otp24h.com/api/v1/rentals \
-H "Authorization: Bearer otp_live_EXAMPLE_NOT_A_REAL_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 8f14e45f-ceea-467a-9f0b-1c2d3e4f5a6b" \
-d '{"channel":"sms","service_code":"telegram","country_code":"US"}'{"success": true, "data": {
"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB",
"channel": "sms",
"status": "waiting_code",
"price": "15000.0000",
"currency": "VND",
"allocation": "+15550000001",
"expires_at": "2026-11-05T12:30:00+00:00",
"created_at": "2026-11-05T12:00:00+00:00",
"service_code": "telegram",
"country_code": "US"
}}allocation is the number/email address issued for the order (not provider information).
/api/v1/rentals/{public_id}
Status of one of your own orders. Once the order has received a code, the response also includes otp_code. Other people's orders return 404.
{"success": true, "data": {"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB", "status": "code_received",
"channel": "sms", "allocation": "+15550000001", "otp_code": "483920", …}}/api/v1/rentals/{public_id}/cancelRequest to cancel the order. No body. May be rejected if it is too late (409 cancel_denied).
{"success": true, "data": {"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB", "status": "cancelled", …}}/api/v1/rentals/{public_id}/finishMark the order as used up. No body.
{"success": true, "data": {"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB", "status": "completed", …}}/api/v1/rentals/{public_id}/another-codeRequest one more code for the same number. No body.
{"success": true, "data": {"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB", "status": "waiting_code", …}}/api/v1/rentalsRental history of the account that owns the calling key (every key of one account sees the same history). Another account's orders never appear, and no parameter can name a different user. Newest first, cursor-paginated.
?limit=— rows per page, 20 by default, 100 at most.?before_id=— the next-page cursor: pass back exactly the value ofdata.next_before_idfrom the previous page. Omit it to get the first page.- No OTP in the list — the code only appears on the status endpoint
GET /api/v1/rentals/{public_id}. - Shares the polling rate limit with the status endpoint, so browsing history never spends the create-order budget.
curl https://otp24h.com/api/v1/rentals?limit=20 \ -H "Authorization: Bearer otp_live_EXAMPLE_NOT_A_REAL_KEY"
{"success": true, "data": {
"rentals": [
{"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB", "status": "completed", "channel": "sms",
"allocation": "+15550000001", "price": "1500.0000", "currency": "VND",
"service_code": "telegram", "country_code": "US",
"created_at": "2026-11-05T12:00:00+00:00", "expires_at": "2026-11-05T12:30:00+00:00"}
],
"count": 1, "limit": 20, "has_more": false, "next_before_id": null
}}/api/v1/webhooks/testSends one signed test event to your own webhook, so you can check the signature and the receiver before depending on it. Needs the webhook.test scope.
Webhooks are created and managed at /account/webhooks; here you only name one by its endpoint_id. Another account's webhook answers 404 — exactly like an id that does not exist.
curl -X POST https://otp24h.com/api/v1/webhooks/test \
-H "Authorization: Bearer otp_live_EXAMPLE_NOT_A_REAL_KEY" \
-H "Content-Type: application/json" \
-d '{"endpoint_id": 12}'{"success": true, "data": {"endpoint_id": 12, "event": "webhook.test", "status": "queued"}}202 means the event is queued and will be delivered like any real event (same signature, same retry policy). At most 5 test sends per hour per webhook; beyond that the answer is 429. A URL pointing into a private network is refused at once (422) instead of being queued.
API for automation tools
For users who run automation tools (bots, Selenium, Puppeteer, your own scripts) — you do not need to be a reseller. The tool sends service and country, and the system rents a number (or email) and returns the exact OTP code ready to use. Everything shares the API key and wallet of your account.
Why two steps? The tool has to enter the phone number (or email) on the target page before the code exists. Step 1 (number) returns the number or email; step 2 (code) waits and returns only the code.
You are charged when the code arrives; if no code comes, the order is refunded automatically, so a failed run costs nothing.
Setup
- Create a key under Account → API keys and tick the scopes
rental.create(get a number),rental.read(get the code),rental.cancel(cancel),rental.request_code(request another code). - Send the key in the header
Authorization: Bearer YOUR_KEYorX-API-Key: YOUR_KEY(recommended). If your tool cannot set headers, only the/api/v1/tool/*group additionally accepts?api_key=YOUR_KEY— the key is then part of the URL, so use this only when you have to and never share the URL. The header always takes priority if both are present. - Services are written as the service code (for example
telegram), and countries as the 2-letter ISO code (VN,US…); case-insensitive. See the list under Service. format=json(default) orformat=text: withtext, the response body is just the value (the OTP code or a status keyword), with no JSON.
/api/v1/tool/numberRents a phone number or an email address. Also accepts POST with the same parameters.
| Parameter | Description |
|---|---|
service | Required. Service code (or exact name). |
country | 2-letter ISO code (or exact name). Required for SMS, ignored for email. |
channel | sms (default) or email. |
domain | Optional, email only: the desired domain. |
max_price | Optional, VND. If the current price is higher, the request is rejected and no order is created. |
request_id | Optional, up to 64 characters. Calling again with the same value and the same parameters returns the exact original order, and no second order is created (safe on a flaky network). The same value with different parameters, or an order that is already closed (cancelled/expired/refunded), returns REQUEST_ID_REUSED — use a request_id new one. While the first call is still running: 409 IDEMPOTENCY_IN_PROGRESS with Retry-After. If the previous attempt clearly failed (no money held): calling again with the same request_id creates a new order. |
format | json or text. |
{"success": true,
"id": "TqtGANIQW0RboqpqZVN8Wfu5vM",
"channel": "sms",
"number": "+84901234567",
"email": null,
"price": "250.0000",
"expires_in": 3600}
For email: number is null and email is the issued address.
format=text returns one line id|number (or id|email).
price is the order amount in VND; expires_in is the seconds left (always recomputed when you call again with the same request_id).
When the system is not sure whether the supplier has issued a number, you get 202 PENDING_REVIEW
with id of the order (text: PENDING_REVIEW|id). Do not create a new order: it is reviewed manually, and you can ask for code or cancel with id that id. Parameters can be sent as a query, a form (application/x-www-form-urlencoded, multipart) or JSON.
/api/v1/tool/codeWaits for the code and returns it. Parameters: id (from step 1), wait (seconds, 0–120, default 0), format.
wait=0 checks once. wait>0 keeps the connection open and returns the code as soon as it arrives (usually within seconds); when wait elapses and there is still no code, it returns 202 runs out without a code, it returns 202 so you can call again. While waiting, the server sends no bytes
, so set the tool-side timeout larger than wait. The default maximum wait is 30 seconds
(a larger wait value is cut back to the server maximum). After another, code always returns
WAITING until a new code arrives — it never returns the old code.
# format=text, mã đã về (HTTP 200): thân phản hồi CHỈ là mã
482913
# format=json
{"success": true, "status": "code_received", "otp": "482913"}
# chưa có mã khi hết wait (HTTP 202)
{"success": false, "status": "waiting"} # text: WAITING| HTTP | Body (text) | Meaning |
|---|---|---|
| 200 | 482913 | Code received. |
| 202 | WAITING | No code yet — call again. |
| 202 | PENDING_REVIEW | The order is under manual review. |
| 410 | EXPIRED | Expired and refunded (or being refunded). |
| 410 | CANCELLED | Order cancelled (refunded or being refunded). |
| 410 | FAILED | The supplier could not provide a number; you are not charged. |
| 404 | NOT_FOUND | This order is not in your account. |
| 429 | RATE_LIMITED | Calling code too often. Wait exactly the number of seconds in Retry-After. |
| 429 | TOO_MANY_WAITS | Too many concurrent waiting requests on one key (max 10). Wait Retry-After seconds. |
/api/v1/tool/cancelCancels the order and refunds it (only while it can still be cancelled). Parameters: id, format. Also accepts POST.
Success: {"success": true, "status": "cancelled"} (text: CANCELLED). Refund in progress: 202 {"success": true, "status": "cancelled_refund_pending"}
(text: CANCELLED_REFUND_PENDING). Result uncertain: 202 PENDING_REVIEW. The code arrived during the cancel, so it cannot be cancelled: 409 CODE_ALREADY_RECEIVED. Cannot be cancelled for another reason: 409 NOT_CANCELLABLE. Cancelling an order that is already cancelled or expired returns the same result as before (safe to retry after a network error).
/api/v1/tool/anotherRequests another code for the same number (free, once the order has already received a code). Parameters: id, format. Also accepts POST.
Success: 202 {"success": true, "status": "waiting"} — then call code. Calling again while the order is already waiting for a new code also returns 202 , and no extra request is created. If it cannot be requested: 409 CANNOT_REQUEST_ANOTHER.
Errors when renting a number
| HTTP | Code | Meaning |
|---|---|---|
| 404 | SERVICE_NOT_FOUND | No such service. |
| 404 | COUNTRY_NOT_FOUND | No such country. |
| 409 | NO_STOCK | Out of numbers for this service and country. |
| 402 | INSUFFICIENT_BALANCE | Insufficient balance. |
| 409 | PRICE_TOO_HIGH | The current price exceeds max_price. |
| 409 | PRICE_CHANGED | The price level you picked is no longer on sale (the price changed or it sold out). Nothing is charged; the response includes the current price levels so you can choose again. |
| 429 | LIMIT_REACHED | The maximum number of active orders has been reached. |
| 422 | INVALID_REQUEST | Missing or invalid parameters. |
| 409 | REQUEST_ID_REUSED | request_id was already used with other parameters, or belongs to a closed order. |
| 409 | IDEMPOTENCY_IN_PROGRESS | The previous call with the same request_id is still running. Wait Retry-After seconds, then call again. |
| 409 | TRY_AGAIN | The amount could not be reserved right now; try again in a few seconds. |
| 422 | AMBIGUOUS_SERVICE | The service name matches more than one service; use the service code. |
| 202 | PENDING_REVIEW | The order is being reviewed manually; the body carries the order id . |
For format=text, the error response body is the code from the table above.
Full examples
# 1. thuê số, rồi nhập số vào trang đích
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://otp24h.com/api/v1/tool/number?service=telegram&country=VN&request_id=run-001"
# {"success":true,"id":"ord_7Kx2","number":"+84901234567", ...}
# 2. chờ mã: câu trả lời chỉ là mã OTP
curl -H "Authorization: Bearer YOUR_API_KEY" \
"https://otp24h.com/api/v1/tool/code?id=ord_7Kx2&wait=60&format=text"
# 482913import requests
API = "https://otp24h.com/api/v1/tool"
H = {"Authorization": "Bearer YOUR_API_KEY"}
n = requests.get(API + "/number", headers=H,
params={"service": "telegram", "country": "VN", "request_id": "run-001"}).json()
print(n["number"]) # nhập vào trang đích
r = requests.get(API + "/code", headers=H,
params={"id": n["id"], "wait": 60, "format": "text"})
if r.status_code == 200:
print(r.text) # 482913
else:
print(r.text) # WAITING / EXPIRED / CANCELLED ...const API = "https://otp24h.com/api/v1/tool";
const H = { Authorization: "Bearer YOUR_API_KEY" };
const n = await (await fetch(
`${API}/number?service=telegram&country=VN&request_id=run-001`, { headers: H })).json();
console.log(n.number); // nhập vào trang đích
const r = await fetch(`${API}/code?id=${n.id}&wait=60&format=text`, { headers: H });
console.log(r.status, await r.text()); // 200 482913Note
- Each key holds at most 10 waiting requests (
wait) at once; beyond that you get429 TOO_MANY_WAITS. While waiting, the system polls the supplier by itself — the tool does not need to poll aggressively. - Use
request_idfor every run, so that an accidental resend is never charged twice. - Does your tool need a different format (for example, a software's own protocol)? Contact us through the support channel in the footer: we build custom APIs on request. Request a custom API
Runnable code examples
The four snippets below do exactly three things: create an order, wait for the code, finish the order. They are not pseudocode — tests/Api/ApiExamplesTest.php checks every call against routes/api.php, against the scope ScopeEnforcementService actually demands, against the RentalInput validator and against the published response contract, so a snippet that drifts from the API turns the test red.
<?php
// POST /api/v1/rentals -> poll GET /api/v1/rentals/{id} -> POST .../finish
$base = 'https://your-install.example';
$token = getenv('OTP_API_KEY'); // otp_live_...
function call(string $method, string $url, string $token, ?array $body = null, ?string $idem = null): array
{
$headers = ["Authorization: Bearer {$token}", 'Accept: application/json'];
if ($body !== null) {
$headers[] = 'Content-Type: application/json';
}
if ($idem !== null) {
$headers[] = "Idempotency-Key: {$idem}";
}
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_TIMEOUT => 30,
]);
if ($body !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body, JSON_UNESCAPED_SLASHES));
}
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
return [$status, json_decode((string) $raw, true)];
}
// 1. create
[$status, $created] = call('POST', "{$base}/api/v1/rentals", $token, [
'channel' => 'sms',
'service_code' => 'facebook',
'country_code' => 'VN',
], 'order-' . bin2hex(random_bytes(8)));
if ($status !== 201) {
exit("create failed: {$status} " . json_encode($created));
}
$id = $created['data']['rental_id'];
// 2. poll — its own rate budget, so polling never blocks the next create
for ($i = 0; $i < 60; $i++) {
[$status, $state] = call('GET', "{$base}/api/v1/rentals/{$id}", $token);
if ($status === 429) {
sleep((int) ($state['retry_after'] ?? 2));
continue;
}
if (($state['data']['status'] ?? '') === 'code_received') {
echo "OTP: " . ($state['data']['otp_code'] ?? '(none)') . PHP_EOL;
break;
}
sleep(2);
}
// 3. finish
[$status, $done] = call('POST', "{$base}/api/v1/rentals/{$id}/finish", $token);
echo "finish: {$status}" . PHP_EOL;import os, time, json, urllib.request, urllib.error
BASE = "https://your-install.example"
TOKEN = os.environ["OTP_API_KEY"]
def call(method, path, body=None, idem=None):
headers = {"Authorization": f"Bearer {TOKEN}", "Accept": "application/json"}
data = None
if body is not None:
headers["Content-Type"] = "application/json"
data = json.dumps(body).encode()
if idem:
headers["Idempotency-Key"] = idem
req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req, timeout=30) as r:
return r.status, json.loads(r.read() or b"{}")
except urllib.error.HTTPError as e:
return e.code, json.loads(e.read() or b"{}")
status, created = call("POST", "/api/v1/rentals", {
"channel": "sms", "service_code": "facebook", "country_code": "VN",
}, idem="order-" + os.urandom(8).hex())
if status != 201:
raise SystemExit(f"create failed: {status} {created}")
rid = created["data"]["rental_id"]
for _ in range(60):
status, state = call("GET", f"/api/v1/rentals/{rid}")
if status == 429:
time.sleep(int(state.get("retry_after", 2)))
continue
if state.get("data", {}).get("status") == "code_received":
print("OTP:", state["data"].get("otp_code"))
break
time.sleep(2)
status, _ = call("POST", f"/api/v1/rentals/{rid}/finish")
print("finish:", status)const BASE = 'https://your-install.example';
const TOKEN = process.env.OTP_API_KEY;
async function call(method, path, body, idem) {
const headers = { Authorization: `Bearer ${TOKEN}`, Accept: 'application/json' };
if (body !== undefined) headers['Content-Type'] = 'application/json';
if (idem) headers['Idempotency-Key'] = idem;
const res = await fetch(BASE + path, {
method,
headers,
body: body === undefined ? undefined : JSON.stringify(body),
});
const text = await res.text();
return [res.status, text ? JSON.parse(text) : {}];
}
const [createStatus, created] = await call('POST', '/api/v1/rentals', {
channel: 'sms', service_code: 'facebook', country_code: 'VN',
}, 'order-' + crypto.randomUUID());
if (createStatus !== 201) throw new Error(`create failed: ${createStatus}`);
const id = created.data.rental_id;
for (let i = 0; i < 60; i++) {
const [status, state] = await call('GET', `/api/v1/rentals/${id}`);
if (status === 429) {
await new Promise((r) => setTimeout(r, (state.retry_after ?? 2) * 1000));
continue;
}
if (state.data?.status === 'code_received') {
console.log('OTP:', state.data.otp_code);
break;
}
await new Promise((r) => setTimeout(r, 2000));
}
const [finishStatus] = await call('POST', `/api/v1/rentals/${id}/finish`);
console.log('finish:', finishStatus);BASE="https://your-install.example"
TOKEN="$OTP_API_KEY"
# 1. create — the Idempotency-Key makes a retry safe
CREATE=$(curl -sS -X POST "$BASE/api/v1/rentals" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-$(openssl rand -hex 8)" \
-d '{"channel":"sms","service_code":"facebook","country_code":"VN"}')
echo "$CREATE"
ID=$(echo "$CREATE" | sed -n 's/.*"rental_id":"\([^"]*\)".*/\1/p')
# 2. poll (own rate budget: 240/min by default)
curl -sS "$BASE/api/v1/rentals/$ID" -H "Authorization: Bearer $TOKEN"
# 3. finish
curl -sS -X POST "$BASE/api/v1/rentals/$ID/finish" -H "Authorization: Bearer $TOKEN"
# 4. history of THIS key, newest first, 20 per page
curl -sS "$BASE/api/v1/rentals?limit=20" -H "Authorization: Bearer $TOKEN"201 on the create step is correct (not 200). While waiting, a 429 only means "slow down" — read Retry-After, call again, and do not create a second order.
5Rental order lifecycle
Statuses the API actually returns (no other internal statuses):
| Status | Meaning | Finished? |
|---|---|---|
| created | Order just created, no number assigned yet. | no |
| reserving | Holding the money and requesting a number. | no |
| waiting_code | Number assigned, waiting for code. | no |
| code_received | Code received (see otp_code). | no |
| completed | The order has been used. | yes |
| cancelled | Cancelled (with refund if any). | yes |
| expired | Expired, no code received. | yes |
| failed | Could not create the order on the provider side. | yes |
| refund_pending | Awaiting refund. | no |
| manual_review | Being handled manually. | no |
GET /api/v1/rentals/{public_id} every
5 seconds in the first 2 minutes, then every 15 seconds. Stop when the status is
completed, cancelled, expired or failed
(or when there is already otp_code). Do not poll more often than once every 1 seconds, or you will hit the rate limit.
6Error code
Every error returns {"success": false, "error": {"code": …, "message": …}}. The table below lists all public codes the API can return — there are no others.
The error envelope may carry two additional fields optional:
error.field (name of the rejected field, only present when the error is caused by submitted data) and
error.incident_id (a lookup code for server-side errors — give this code to support). They never contain internal details.
| Code | HTTP | Message |
|---|---|---|
validation_error |
422 | The submitted data is invalid. |
account_banned |
403 | Access denied. |
email_not_verified |
403 | Please verify your email address before continuing. |
unauthorized |
401 | Not authenticated. |
forbidden |
403 | Access denied. |
csrf_token_mismatch |
403 | Your session expired. Please reload the page and try again. |
service_unavailable |
503 | The service is temporarily unavailable. Please try again later. |
insufficient_balance |
402 | Insufficient balance. Please top up your wallet. |
insufficient_funds |
402 | Insufficient balance. Please top up your wallet. |
no_numbers_available |
503 | No numbers are available right now. Please try again later. |
all_providers_failed |
503 | No numbers are available right now. Please try again later. |
no_route |
503 | No numbers are available right now. Please try again later. |
provider_unavailable |
503 | Service temporarily unavailable. Please try again later. |
routing_unavailable |
503 | Service temporarily unavailable. Please try again later. |
rental_not_found |
404 | Rental not found. |
not_found |
404 | The requested resource was not found. |
method_not_allowed |
405 | This method is not allowed for the requested resource. |
provider_unknown |
409 | The request is being confirmed. Please check again shortly. |
invalid_state |
409 | Cannot perform this action in the current state. |
state_conflict |
409 | The rental changed state. Please refresh and try again. |
cancel_denied |
409 | Cannot cancel — too late or already processing. |
already_finished |
409 | This number is already finished, so no further code can be requested. The order is now marked Done. |
provider_rejected |
409 | No further code can be requested for this number. |
request_failed |
503 | Could not request another code right now. Please try again in a moment. |
cancel_ambiguous |
409 | The cancellation is being confirmed. Please check again shortly. |
refund_pending |
409 | Cancellation confirmed. The refund is being processed. |
rate_limited |
429 | Too many requests. Please slow down. |
too_many_active_orders |
429 | You already have too many rentals in progress. Finish or cancel some before renting again. |
idempotency_key_reused |
409 | This idempotency key was already used with a different request. |
idempotency_in_progress |
409 | A request with this idempotency key is still being processed. |
payment_method_disabled |
503 | This payment method is currently unavailable. |
payment_not_configured |
503 | This payment method is currently unavailable. |
payment_already_pending |
409 | You already have an invoice waiting for payment. |
amount_out_of_range |
422 | The submitted amount is not accepted. |
amount_decimals |
422 | Enter an amount with at most 2 decimals. |
invalid_request |
422 | The request is invalid. |
request_id_reused |
409 | This request_id cannot be reused: it was used with different parameters or belongs to a closed order. |
service_not_found |
404 | The requested service was not found. |
country_not_found |
404 | The requested country was not found. |
domain_unavailable |
404 | The requested email domain is not available. |
no_stock |
409 | No numbers are available for this request right now. |
price_too_high |
409 | The current price exceeds the requested maximum. |
price_changed |
409 | The price you picked is no longer available. Please choose again. |
limit_reached |
429 | Too many rentals are already in progress. |
not_cancellable |
409 | This rental cannot be cancelled in its current state. |
expired |
410 | This rental has expired. |
cancelled |
410 | This rental was cancelled. |
pending_review |
202 | This rental is being reviewed manually. |
cannot_request_another |
409 | Another code cannot be requested in the current state. |
too_many_waits |
429 | Too many code waits are already running for this key. |
waiting |
202 | The code is not ready yet. |
try_again |
409 | Could not reserve the amount, try again. |
code_already_received |
409 | The code already arrived, so the rental cannot be cancelled. |
failed |
410 | This rental failed. |
ambiguous_service |
422 | More than one service matches that name; use its code instead. |
too_many_pending_same_amount |
422 | You already have the maximum number of pending deposits of this amount. |
too_many_pending |
422 | You already have 3 unpaid invoices. Pay one or wait until it expires before creating a new one. |
pending_exists |
409 | You already have an unpaid Binance Pay invoice. Pay it or wait until it expires. |
name_in_use |
409 | This Binance name is being used for another unpaid invoice right now. Try again in a few minutes, or use a different Binance name. |
payment_busy |
503 | Too many requests right now. Please try again in a moment. |
routing_loop |
409 | This request cannot be routed: it would return to a server it already visited. |
max_upstream_hops |
409 | This request cannot be routed: it has passed too many servers. |
federation_error |
409 | This request cannot be routed between servers. |
internal_error |
500 | An internal error occurred. Please try again later. |
too_many_active_orders means you have too many unfinished orders at the same time. This limit is set by the operator for each account; see the current number on your account page or ask support. Wait for some orders to finish or be cancelled, then try again.
7Seller webhooks
Sign up and manage at /account/webhooks: add a receiving address, choose events, enable/disable, rotate the secret, send a test and resend failed deliveries.
Event
rental.created— when the order moves to the corresponding status.rental.code_received— when the order moves to the corresponding status.rental.completed— when the order moves to the corresponding status.rental.cancelled— when the order moves to the corresponding status.rental.expired— when the order moves to the corresponding status.rental.failed— when the order moves to the corresponding status.webhook.test— test delivery, contains only{"event":"webhook.test","created_at":…}.
Payload structure
{"event": "rental.completed",
"id": "rental.completed:12345",
"timestamp": 1793906237,
"data": {"rental_id": "01HZX8K4Q7Y2V5N6M3P8R9T0AB", "channel": "sms",
"status": "completed", "completed_at": "2026-11-05T12:00:00Z"}}
data contains only the public information of the order (order code, channel, status, selling price, currency, time, partially masked number/email). No internal information.
Outgoing headers
Content-Type: application/json X-Webhook-Signature: <timestamp>.<base64(HMAC-SHA256)>
Signature = base64(hmac_sha256(timestamp + "." + raw body, secret)), using the exact secret whsec_… you received when creating the webhook (shown only once). The timestamp is in Unix seconds; reject it if it is off by more than 300 seconds to prevent replay.
Verify signature
<?php
$secret = 'whsec_EXAMPLE'; // your webhook secret
$header = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '';
$rawBody = file_get_contents('php://input');
[$ts, $sig] = array_pad(explode('.', $header, 2), 2, '');
if (abs(time() - (int) $ts) > 300) { http_response_code(400); exit; }
$expected = base64_encode(hash_hmac('sha256', $ts . '.' . $rawBody, $secret, true));
if (!hash_equals($expected, $sig)) { http_response_code(401); exit; }
http_response_code(200);import base64, hashlib, hmac, time
secret = b"whsec_EXAMPLE"
header = request.headers.get("X-Webhook-Signature", "")
raw_body = request.get_data() # bytes THÔ, chưa parse JSON
ts, sig = (header.split(".", 1) + ["", ""])[:2]
if abs(time.time() - int(ts)) > 300:
return "", 400
expected = base64.b64encode(
hmac.new(secret, ts.encode() + b"." + raw_body, hashlib.sha256).digest()
).decode()
if not hmac.compare_digest(expected, sig):
return "", 401
return "", 200const crypto = require('crypto');
const secret = 'whsec_EXAMPLE';
const header = req.headers['x-webhook-signature'] || '';
const rawBody = req.rawBody; // chuỗi THÔ, chưa parse JSON
const [ts, sig] = header.split('.');
if (Math.abs(Math.floor(Date.now() / 1000) - Number(ts)) > 300) return res.sendStatus(400);
const expected = crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('base64');
const a = Buffer.from(expected);
const b = Buffer.from(sig || '');
if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) return res.sendStatus(401);
res.sendStatus(200);Retry, timeout and manual resend
- Each delivery is attempted up to 5 times, spaced out 1 minutes, 5 minutes, 15 minutes, 1 hours, 6 hours.
- Timeout per call is 10 seconds.
- Response
2xx= delivered. Temporary errors (timeout, 429, 5xx) will be retried; permanent errors (400/401/403/404/409/422) are marked failed immediately. - After 5 attempts still failing, the delivery moves to
failed. After fixing your server, go to /account/webhooks click Resend (up to 10 times/hour per webhook). - If the response has the header
Retry-After(on a 429), the system honors that value (up to 1 hour).
Idempotent theo event_id
id in the payload is the stable code of the event (e.g. rental.completed:12345). The network may cause the same event to arrive twice: save the id already processed and skip it if you see it again, to avoid recording duplicates.
Technical requirements for the receiving address
- Only accepts https://; do not use
http://. - Do not use internal addresses,
localhost, or private IPs — the system blocks them to protect the server. - Do not embed credentials (
user:pass@) or the sign#trong URL. - Maximum per account 5 webhook.
Order events are scanned in batches every ~15 seconds, and delivery runs on its own cycle: a webhook may arrive up to ~45 seconds relative to when the event happened. Events that occurred before you created the webhook will not be resent.
8Change log
Each change visible from outside all have a row here, newest first. Change types: added (added), changed (behavior change),
fixed (bug fix), deprecated (deprecated), removed (removed).
Transparent v1 we never rename or remove published fields. Adding a new field is a compatible change — it is still listed here so you know to read it.
| Date | Version | Kind | Changes |
|---|---|---|---|
2026-11-29 | v1 | added |
GET /api/v1/countries: mỗi quốc gia có thêm trường code — đúng giá trị tham số country= chấp nhận (mã ISO nếu có, nếu không là mã tên quốc gia). iso2 giữ nguyên, có thể là null với quốc gia chưa có mã ISO. |
2026-11-26 | v1 | added |
GET /api/v1/domains — danh sách miền email đang còn hàng, mỗi mục chỉ có trường domain. Không lộ nguồn cấp hay giá vốn. Dùng làm nguồn cho ô chọn miền ở kênh email. |
2026-11-26 | v1 | added |
POST /api/v1/rentals: trường domain trên kênh email giờ là TUỲ CHỌN. Bỏ trống nghĩa là "miền rẻ nhất còn hàng"; chỉ định thì lọc cứng, và miền không có hàng trả 404 DOMAIN_UNAVAILABLE (không trừ tiền, không gọi hệ thống bên ngoài). |
2026-11-25 | v1 | added |
POST /api/v1/webhooks/test — sends one signed webhook.test event to a webhook of the account that owns the calling key. Body {"endpoint_id": 12} (or endpoint_id as a form field). Answers 202 with data.endpoint_id, data.event and data.status (queued) — the event is queued and the worker delivers it like a real one. Needs the new webhook.test scope; at most 5 sends per hour per webhook. IDOR answers 404, a disabled webhook answers 409, a private-network URL is refused with 422. |
2026-11-25 | v1 | added |
GET /api/v1/rentals — the rental history of the account that owns the calling key, cursor-paginated. Returns data.rentals[] with the same DTO shape as the status endpoint (no internal fields, no cost price, no routing score), plus data.count, data.limit, data.has_more and data.next_before_id (the next-page cursor; null at the end). Parameters: ?limit= (20 by default, 100 at most) and ?before_id=. Needs the rental.read scope. This endpoint does NOT return the OTP — the code is only on the status endpoint. |
2026-11-25 | v1 | changed |
Rate limiting while polling. GET /api/v1/rentals/{id} and GET /api/v1/rentals use their own bucket (240 requests per minute per key by default, adjustable at Admin → Security → API), so a tool polling every second no longer eats the 60/minute budget of the write endpoints. Past the threshold the answer is 429 with Retry-After. |
2026-11-23 | v1 | fixed |
GET /api/v1/meta trả đúng hợp đồng liên kết: thêm
protocol, api_version, instance_id and
capability_list — DANH SÁCH năng lực thật của bản cài
(cancel/finish/next_code/rentals
nay bật đúng, không còn cứng rentals=false).
capabilities GIỮ NGUYÊN kiểu object cờ boolean như bản v1 đã công bố
(chỉ giá trị rentals đổi thành true);
capability_flags vẫn là bản sao của object đó. Không xoá trường nào,
không đổi kiểu trường nào.
|
2026-11-16 | v1 | added |
Choose a price level when renting: /api/v1/offers gains a tiers array and POST /api/v1/rentals gains an optional price field. If the chosen level is no longer on sale, 409 PRICE_CHANGED is returned and nothing is charged. Existing fields are unchanged. |
2026-11-15 | v1 | added |
API for automation tools (number, code, cancel, another): shares the existing API keys and rental.* scopes; also accepts api_key in the URL, format=text, request_id to prevent duplicates, and max_price. |
2026-11-10 | v1 | fixed |
Some order codes issued by the system earlier were shorter than 26 characters; now every code is usable. Previously those codes were rejected as "invalid" when you read the status, cancelled, finished or requested another code, even though the system itself had issued them to you. Newly issued codes are always 26 characters long. |
2026-11-10 | v1 | added |
Current response contract locked: the shape of all 42 response branches (10 endpoints, including error branches) has been captured and locked by tests. From now on, every change to a field name / type / order of appearance must come with a row in this table. |
2026-11-10 | v1 | fixed |
expires_at and created_at in the rental order response is always UTC time in ISO-8601 format with the suffix +00:00, even when the server uses another time zone. Previously the values were read in the wrong time zone and so were off.
|
2026-11-09 | v1 | fixed |
Errors that occur midway on the money path and the order path (including PHP system errors, not just exceptions) now always return a JSON error envelope that matches the contract, with no more blank pages or stack traces. The returned status code is still internal_error.
|
2026-11-06 | v1 | added |
Cap on unfinished orders per account: exceeding the cap returns
429 too_many_active_orders (separate code, not merged into
invalid_state) and no call the provider.
|
2026-11-06 | v1 | added |
Webhooks for sellers: register at /account/webhooks, signature
X-Webhook-Signature, resend failed deliveries. Details in section 7.
|
2026-11-05 | v1 | changed |
When the "stop accepting new work" mode is on, POST /api/v1/rentals returns
503 with header Retry-After. The read, cancel, finish and get-code endpoints of orders already exists still runs normally.
|
2026-11-03 | v1 | changed |
Accounts with unverified email (when the operator enables the requirement) receive
403 email_not_verified when creating an order; all read operations are not blocked.
|
2026-11-03 | v1 | changed |
Every public error code uses one fixed message sentences that never contain internal details. The full table is in section 6; it lists every code the API can return. |
Locked contract: 2026-11-10. This page and the locked copy must be dated the same day — a mismatch makes the test red.
9Changes / version
The current version is v1 (/api/v1). Throughout v1, we
does not rename or remove fields published; changes only add new fields. Any breaking change will be released in the next major version.
More questions: ask your support team directly. Keys and webhooks: see /account/api and /account/webhooks.