9211SMS API Documentation
REST & SMS-Activate compatibility · PKR · API wallet isolation
The API is live. API access, purchases, top-ups and webhooks are controlled by independent switches, and your account must be approved for API access first. Gate order is disabled, then maintenance, then authentication: full website maintenance, when enabled, takes precedence over authentication errors, but a disabled API switch answers plain-text 404 before either.
API introduction
Buy virtual numbers and receive SMS codes from your own software. Two styles are offered — use whichever your software supports:
- REST (JSON) —
https://9211sms.com/api/v1/... - SMS-Activate compatible —
https://9211sms.com/api/v1/stubs/handler_api.php
These are the production addresses. This reference describes the implementation in this project; the API host above is the live production host. The Playground sends requests only to the current website origin, never to the production host from Preview.
Status: the API is live. API access, purchases, top-ups and webhooks are controlled by independent switches, and your account must be approved for API access first. While the API switch is on, unauthenticated requests are refused with
401 invalid_key, not404; a disabled API switch answers plain-text404 Not Found.
REST endpoint reference
GET/api/v1/balanceWallet balance
Read your separate API wallet balance and frozen state in PKR.
https://9211sms.com/api/v1/balance
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request GET 'https://9211sms.com/api/v1/balance' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": {
"balance_pkr": 250,
"currency": "PKR",
"frozen": false
}
}Illustrative payload only, not a live response. Error HTTP statuses: 401, 403, 404 (API disabled), 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}GET/api/v1/servicesServices
List customer-visible services from the synced catalog.
https://9211sms.com/api/v1/services
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request GET 'https://9211sms.com/api/v1/services' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": [
{
"code": "wa",
"name": "WhatsApp"
}
]
}Illustrative payload only, not a live response. Error HTTP statuses: 401, 403, 404 (API disabled), 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}GET/api/v1/countriesCountries
List available country codes, names and ISO identifiers.
https://9211sms.com/api/v1/countries
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request GET 'https://9211sms.com/api/v1/countries' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": [
{
"code": "22",
"name": "India",
"iso": "IN"
}
]
}Illustrative payload only, not a live response. Error HTTP statuses: 401, 403, 404 (API disabled), 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}GET/api/v1/pricesPrices & availability
Read effective API prices and synced availability. Filters are optional; this does not reserve stock.
https://9211sms.com/api/v1/prices
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
| service | query | No | Catalog service code; 1–20 lowercase letters, digits or underscores. |
| country | query | No | Catalog country code; 1–4 digits. Only an omitted parameter means no filter — an empty value is passed through as a literal filter and matches nothing. |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request GET 'https://9211sms.com/api/v1/prices?service=wa&country=22' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": [
{
"service": "wa",
"service_name": "WhatsApp",
"country": "22",
"country_name": "India",
"country_iso": "IN",
"price_pkr": 55.5,
"count": 120,
"currency": "PKR"
}
]
}Illustrative payload only, not a live response. Error HTTP statuses: 400, 401, 403, 404 (API disabled), 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}POST/api/v1/ordersPurchase a number
Reserve an API order and atomically charge only the API wallet before requesting a number. Check the returned status, not just the HTTP success code.
https://9211sms.com/api/v1/orders
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
| service | body | Yes | Catalog service code; 1–20 lowercase letters, digits or underscores. |
| country | body | Yes | Country code; 1–4 digits (string or number accepted). |
| max_price | body | No | PKR ceiling, greater than 0 and less than 10,000,000. |
| Idempotency-Key | header | No | Recommended: 1–100 characters from A–Z, a–z, 0–9, dot, underscore, colon or hyphen. Reuse only for the same request with the same API key. |
JSON request body: service, country, optional max_price. Send Content-Type: application/json.
Request examples
curl --request POST 'https://9211sms.com/api/v1/orders' \
--header "Authorization: Bearer $SMS9211_API_KEY" \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: integration-order-0001' \
--data '{"service":"wa","country":"22","max_price":60}'Response schema example · 201 new result, 200 replay, 202 under review
{
"ok": true,
"data": {
"id": 1042,
"status": "waiting",
"under_review": false,
"service": "wa",
"country": "22",
"phone": "+919876543210",
"price_pkr": 55.5,
"otp_code": null,
"created_at": "2026-11-10T12:00:00Z",
"expires_at": "2026-11-10T12:20:00Z",
"refunded": false,
"reason": null
},
"replay": false
}Illustrative payload only, not a live response. Error HTTP statuses: 400, 401, 402, 403, 404 (API disabled), 409, 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}GET/api/v1/orders/{id}Order status & OTP
Read an owned order. May poll the supplier or complete an elapsed OTP grace period; not a passive history read.
https://9211sms.com/api/v1/orders/{id}
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
| id | path | Yes | Positive numeric public order ID returned by purchase; not the internal UUID. |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request GET 'https://9211sms.com/api/v1/orders/1042' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": {
"id": 1042,
"status": "otp_received",
"under_review": false,
"service": "wa",
"country": "22",
"phone": "+919876543210",
"price_pkr": 55.5,
"otp_code": "123456",
"created_at": "2026-11-10T12:00:00Z",
"expires_at": "2026-11-10T12:20:00Z",
"refunded": false,
"reason": null
}
}Illustrative payload only, not a live response. Error HTTP statuses: 401, 403, 404, 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}POST/api/v1/orders/{id}/cancelCancel an order
Claim cancellation, re-check OTP and request supplier cancellation. Refund only after confirmation, once. No refund after a code.
https://9211sms.com/api/v1/orders/{id}/cancel
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
| id | path | Yes | Owned public order ID. |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request POST 'https://9211sms.com/api/v1/orders/1042/cancel' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": {
"id": 1042,
"status": "cancelled",
"under_review": false,
"service": "wa",
"country": "22",
"phone": "+919876543210",
"price_pkr": 55.5,
"otp_code": null,
"created_at": "2026-11-10T12:00:00Z",
"expires_at": "2026-11-10T12:20:00Z",
"refunded": true,
"reason": null
}
}Illustrative payload only, not a live response. Error HTTP statuses: 401, 403, 404, 409, 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}POST/api/v1/orders/{id}/finishFinish an order
Complete an order after OTP receipt. Finishing an already completed order is successful. No wallet refund.
https://9211sms.com/api/v1/orders/{id}/finish
Authentication: Bearer or X-API-Key header. Approved, unlocked account; active key and allowed IP. Order actions require ownership; purchases also require enabled purchase switches and an unfrozen funded API wallet. No scopes header.
| Parameter | Location | Required | Description |
|---|---|---|---|
| Authorization | header | Yes* | Bearer API key (*or X-API-Key instead). |
| id | path | Yes | Owned public order ID. |
No JSON request body. No other query/body parameters are implemented.
Request examples
curl --request POST 'https://9211sms.com/api/v1/orders/1042/finish' \
--header "Authorization: Bearer $SMS9211_API_KEY"Response schema example · 200
{
"ok": true,
"data": {
"id": 1042,
"status": "completed",
"under_review": false,
"service": "wa",
"country": "22",
"phone": "+919876543210",
"price_pkr": 55.5,
"otp_code": "123456",
"created_at": "2026-11-10T12:00:00Z",
"expires_at": "2026-11-10T12:20:00Z",
"refunded": false,
"reason": null
}
}Illustrative payload only, not a live response. Error HTTP statuses: 401, 403, 404, 409, 429, 500, 503. See Error codes for meanings.
{
"ok": false,
"error": {
"code": "invalid_key",
"message": "Missing, invalid or revoked API key."
}
}SMS-Activate action reference
getBalanceGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
No action-specific parameters, but service/country are validated globally for every action before dispatch, so a stray invalid service or country returns BAD_SERVICE/BAD_COUNTRY. Reads the separate API wallet in PKR.
Required fields: api_key and action=getBalance. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=getBalance'Response schema example · HTTP 200
ACCESS_BALANCE:250.00Example only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
getCountriesGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
No action-specific parameters, but service/country are validated globally for every action before dispatch, so a stray invalid service or country returns BAD_SERVICE/BAD_COUNTRY. Returns a JSON country map.
Required fields: api_key and action=getCountries. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=getCountries'Response schema example · HTTP 200
{"22":{"id":22,"eng":"India","iso":"IN","visible":1}}Example only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
getNumbersStatusGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
country optional, defaults to 0; 1–4 digits. 0 is not a wildcard and matches no country, so pass a real country code to get counts — with the default 0 the result is {}. Returns synced stock counts as strings; a null count on a returned row is reported as zero, while an unknown service/country yields no keys at all.
Required fields: api_key and action=getNumbersStatus. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=getNumbersStatus' \
--data-urlencode 'country=22'Response schema example · HTTP 200
{"wa_0":"120"}Example only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
getPricesGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
service and country optional. Service: 1–20 lowercase letters/digits/underscores; country: 1–4 digits. Only an omitted parameter means no filter — an empty value is passed through as a literal filter and matches nothing. Returns PKR costs.
Required fields: api_key and action=getPrices. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=getPrices' \
--data-urlencode 'service=wa' \
--data-urlencode 'country=22'Response schema example · HTTP 200
{"22":{"wa":{"cost":55.5,"count":120}}}Example only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
getNumberGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
service required; country defaults to 0; optional maxPrice in PKR, greater than 0 and below 10,000,000. 0 is not a wildcard and matches no country — a real country code is required to buy a number. No idempotency support. Held purchase: ORDER_UNDER_REVIEW:1042; refunded refusal: NO_NUMBERS.
Required fields: api_key and action=getNumber. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=getNumber' \
--data-urlencode 'service=wa' \
--data-urlencode 'country=22' \
--data-urlencode 'maxPrice=60'Response schema example · HTTP 200
ACCESS_NUMBER:1042:919876543210Example only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
getStatusGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
Positive numeric public id required. Other status answers: STATUS_WAIT_CODE and STATUS_CANCEL. An under-review order polls as STATUS_WAIT_CODE.
Required fields: api_key and action=getStatus. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=getStatus' \
--data-urlencode 'id=1042'Response schema example · HTTP 200
STATUS_OK:123456Example only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
setStatusGET / POST
https://9211sms.com/api/v1/stubs/handler_api.php
Positive public id required; status=8 cancels (OTP recheck/confirmed refund only), status=6 finishes (ACCESS_ACTIVATION). No other statuses are supported; they return BAD_STATUS.
Required fields: api_key and action=setStatus. Approved, unlocked account, active key and allowed IP; owned orders only. Purchases also require a funded/unfrozen API wallet and enabled switches. POST header: application/x-www-form-urlencoded. No JSON body or path parameters. Query fields take precedence over form fields.
curl --request POST 'https://9211sms.com/api/v1/stubs/handler_api.php' \
--data-urlencode "api_key=$SMS9211_API_KEY" \
--data-urlencode 'action=setStatus' \
--data-urlencode 'id=1042' \
--data-urlencode 'status=8'Response schema example · HTTP 200
ACCESS_CANCELExample only, not a live response. Normal refusals also use 200 (BAD_KEY, BANNED, BAD_ACTION and action-specific tokens). Disabled: 404 Not Found; rate limit: 429 TOO_MANY_REQUESTS; maintenance: 503 MAINTENANCE; internal failure: 500 ERROR_SQL. See SMS-Activate error answers for all supported tokens.
API Playground
Current-origin requests only. Keys stay in memory and are cleared on sign-out or leaving this page. Catalog and balance requests cannot purchase numbers. Order polling, purchases, cancellation and finish are unavailable here. Disabled API returns a real 404.
Sign in to use PlaygroundCurrency and wallet
- All prices and balances are in Pakistani Rupees (PKR). Monetary JSON values are numbers rounded to 2 decimals;
55.5and55.50represent the same amount. - API orders are paid only from your API wallet. Your website wallet is never touched, and money never moves between the two wallets.
- Top up the API wallet from API Access → API wallet using the same payment methods as the website.
- API prices are the website prices unless 9211SMS sets a separate API price.
GET /api/v1/pricesalways shows the price you will actually be charged.
Authentication
Create a key in API Dashboard → API keys. The key looks like sk9211_ followed by 48 lowercase hexadecimal characters and is shown once — store it safely. We only keep a fingerprint of it.
- REST: send it in a header —
Authorization: Bearer sk9211_...(orX-API-Key: sk9211_...). Keys in the URL are ignored for REST. - SMS-Activate: send it as
api_key=sk9211_...(query string or form body), like SMS-Activate.
A key can be limited to exact IP addresses (not CIDR ranges) by your administrator. Revoked keys stop working at once. REST prefers a Bearer header over X-API-Key when both are provided. Do not send both.
Limits
| Limit | Value |
|---|---|
| Requests per key | 60 per minute (may be set per account) |
| Whole API | 1,200 per minute |
| Wrong/invalid keys from one IP | 30 per minute, then all requests from that IP are refused for the rest of the minute |
| Status checks with the supplier | one per order every 12 seconds (faster polling just returns the saved status) |
| Active orders | 10 at a time (may be set per account) |
REST responses after successful authentication and maintenance checks include X-RateLimit-Limit and X-RateLimit-Remaining. Gate-level per-key/global 429 responses include Retry-After: 60; too_many_active does not. Compatibility responses have neither rate-limit headers nor Retry-After. Limits use fixed calendar-minute windows. At the invalid-key IP threshold even valid keys from that IP get a generic authentication error, not HTTP 429, until the next minute.
Order life cycle
- Buy — your API wallet is charged first, then a number is requested from the supplier.
- Waiting — poll the status (every 5–15 seconds is plenty) until a code arrives. Expiry defaults to 20 minutes from number attachment and is configurable; use the returned
expires_at, not a timer based oncreated_at. - Code received — the order completes automatically 2 minutes after the first code, or immediately when you finish it.
- Cancel / expiry — if no code arrived, cancelling (or expiry) refunds the full price to your API wallet, once.
- Wrong country — when the selected country has a known dialling code and the returned number does not match it, the number is hidden while cancellation is attempted. Refund occurs only after confirmed cancellation, once. It may remain pending or enter review after 30 minutes without confirmation. If a code already arrived, no refund is issued. An unavailable/unknown dialling code cannot be checked. A confirmed refund returns
reason: "wrong_country"(SMS-Activate purchase:NO_NUMBERS). - Under review — if the supplier's answer is unclear (for example a timeout), the order is held and checked by our team. You are never charged twice; if no number was created, the money is returned.
No refund is given once a code has been received.
REST API
Handler responses are JSON: {"ok": true, "data": ...} or {"ok": false, "error": {"code": "...", "message": "..."}}. Exception: while API access is disabled all endpoints return plain-text Not Found with HTTP 404. Check Content-Type/status before parsing JSON. Do not assume framework-level failures are JSON.
GET /api/v1/balance
curl -H "Authorization: Bearer $KEY" https://9211sms.com/api/v1/balance{"ok": true, "data": {"balance_pkr": 250.00, "currency": "PKR", "frozen": false}}GET /api/v1/services · GET /api/v1/countries
{"ok": true, "data": [{"code": "wa", "name": "WhatsApp"}]}
{"ok": true, "data": [{"code": "22", "name": "India", "iso": "IN"}]}GET /api/v1/prices?service=wa&country=22
Both filters are optional.
{"ok": true, "data": [{"service": "wa", "service_name": "WhatsApp", "country": "22", "country_name": "India",
"country_iso": "IN", "price_pkr": 55.50, "count": 120, "currency": "PKR"}]}POST /api/v1/orders — buy a number
curl -X POST https://9211sms.com/api/v1/orders \
-H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: my-order-0001" \
-d '{"service": "wa", "country": "22", "max_price": 60}'max_price(optional, PKR): refuse if the current price is higher.Idempotency-Key(optional, recommended, up to 100 ofA-Z a-z 0-9 . _ : -): repeating the same service/country with the same API key and reference returns the same order and never charges twice. Changingmax_pricealone still replays the original order; a different service or country conflicts. Switching API keys creates a different idempotency scope. A replay returns before the availability, price, wallet and active-order checks, so those checks never refuse a replay; the only temporary replay refusal is the per-user purchase lock (409 purchase_in_progress) while another purchase of yours is running. Retain the original reference.
201 Created (or 200 for a repeat, 202 when held for review):
Inspect data.status and data.refunded on every success. A clear supplier refusal after reservation can return HTTP 201 and ok: true with a failed, refunded order. Under-review replays remain HTTP 202. A successful HTTP response is not a promise that a usable number was issued.
{"ok": true, "replay": false, "data": {"id": 1042, "status": "waiting", "under_review": false, "service": "wa",
"country": "22", "phone": "+919876543210", "price_pkr": 55.50, "otp_code": null,
"created_at": "2026-11-10T12:00:00Z", "expires_at": "2026-11-10T12:20:00Z", "refunded": false, "reason": null}}Order status values: purchasing, waiting, otp_received, completed, cancelled, expired, failed, under_review.
GET /api/v1/orders/{id} — status and code
Returns the same order object. When a code arrives: "status": "otp_received", "otp_code": "123456".
POST /api/v1/orders/{id}/cancel
Cancels and refunds if no code has arrived. Some numbers cannot be cancelled in their first minutes (early_cancel_denied) — retry a little later.
POST /api/v1/orders/{id}/finish
Completes an order that has received a code.
REST error codes
| HTTP | code | Meaning |
|---|---|---|
| 400 | bad_request |
Missing or invalid parameters |
| 401 | invalid_key |
Missing, invalid or revoked key |
| 402 | insufficient_balance |
Not enough API wallet balance |
| 403 | account_refused |
Account not approved, suspended, banned or locked |
| 403 | ip_refused |
IP not allowed for this key |
| 403 | purchases_disabled |
API purchases are switched off |
| 403 | wallet_frozen |
API wallet is frozen |
| 404 | not_found |
Order not found (or not yours) |
| 409 | no_numbers |
No numbers for this service/country |
| 409 | price_above_max |
Price is above max_price (data.price_pkr shows it) |
| 409 | idempotency_conflict |
Same API key/reference reused for a different service or country |
| 409 | purchase_in_progress |
Another purchase of yours is running — retry |
| 409 | otp_received / already_closed / under_review / no_otp_yet / cancel_in_progress / early_cancel_denied |
Order state does not allow this action |
| 429 | rate_limited / global_rate_limited / too_many_active |
Slow down, or close some orders |
| 503 | maintenance |
9211SMS is under maintenance |
| 503 | provider_unavailable / try_again |
Temporary supplier problem — nothing was lost, retry |
| 500 | internal |
Unexpected error — retry |
SMS-Activate compatible API
Address: https://9211sms.com/api/v1/stubs/handler_api.php — GET, or POST as application/x-www-form-urlencoded data. Query parameters take precedence over form fields. Do not use multipart form data. Answers are plain text unless noted. Prices are in PKR (not roubles). Normal authentication/parameter/order errors use HTTP 200; inspect the answer token. Compatibility purchases have no idempotency parameter or header support: never blindly repeat getNumber after an unclear result. Use REST for safely replayable purchasing.
| Action | Parameters | Success answer |
|---|---|---|
getBalance |
— | ACCESS_BALANCE:250.00 |
getCountries |
— | JSON {"22": {"id": 22, "eng": "India", "iso": "IN", "visible": 1}} |
getNumbersStatus |
country (optional, defaults to 0 — 0 is not a wildcard and matches no country; pass a real country code for counts) |
JSON {"wa_0": "120"} |
getPrices |
service, country (optional) |
JSON {"22": {"wa": {"cost": 55.5, "count": 120}}} |
getNumber |
service required; country defaults to 0 — 0 is not a wildcard and matches no country, so a real country code is required; maxPrice optional |
ACCESS_NUMBER:1042:919876543210 |
getStatus |
id |
STATUS_WAIT_CODE, STATUS_OK:123456, STATUS_CANCEL |
setStatus |
id, status=8 (cancel) |
ACCESS_CANCEL |
setStatus |
id, status=6 (finish) |
ACCESS_ACTIVATION |
curl --request POST https://9211sms.com/api/v1/stubs/handler_api.php \
--data-urlencode "api_key=$KEY" \
--data-urlencode "action=getNumber" \
--data-urlencode "service=wa" \
--data-urlencode "country=22"SMS-Activate error answers
| Answer | Meaning |
|---|---|
BAD_KEY |
Missing, invalid or revoked key (or IP not allowed) |
BANNED |
Account not approved, suspended, banned or locked |
BAD_ACTION / BAD_SERVICE / BAD_COUNTRY / BAD_STATUS |
Invalid request |
NO_BALANCE |
Not enough API wallet balance |
NO_NUMBERS |
No numbers available (any charge has been returned) |
WRONG_MAX_PRICE / WRONG_MAX_PRICE:55.5 |
Invalid maximum / current price above maxPrice (not fixed-width decimal text) |
WALLET_FROZEN / PURCHASES_DISABLED |
Wallet frozen / purchases switched off |
TOO_MANY_ACTIVE |
Too many active orders |
NO_ACTIVATION |
Order not found |
STATUS_ALREADY_CHANGED |
Order already closed |
EARLY_CANCEL_DENIED |
Too early to cancel — retry shortly |
ORDER_UNDER_REVIEW:1042 / ORDER_UNDER_REVIEW |
Purchase held for review / order action refused while under review; status polling returns STATUS_WAIT_CODE |
TRY_AGAIN |
Temporary problem — retry |
TOO_MANY_REQUESTS (HTTP 429) |
Rate limit |
MAINTENANCE (HTTP 503) |
9211SMS is under maintenance |
ERROR_SQL (HTTP 500) |
Unexpected error — retry |
Webhooks
Optional. Add an https:// address in API Access → Webhook. A signing secret (whsec_...) is shown once.
Events: order.otp_received, order.completed, order.cancelled, order.expired, order.failed, order.under_review. Each order/event pair is queued once when global and customer webhook settings allow it; delivery may repeat. The queue is best-effort and cannot interrupt an order. Polling remains necessary. Payloads are transition-time snapshots, not current REST order objects; the webhook order includes currency but omits under_review and order timestamps.
POST /your-webhook HTTP/1.1
Content-Type: application/json
X-9211SMS-Event: order.otp_received
X-9211SMS-Delivery: 5b1d0c1e-...
X-9211SMS-Signature: t=1799990000,v1=5f2c...e1
{"event": "order.otp_received", "created_at": "2026-11-10T12:01:00Z",
"order": {"id": 1042, "status": "otp_received", "service": "wa", "country": "22", "phone": "+919876543210",
"price_pkr": 55.50, "currency": "PKR", "otp_code": "123456", "refunded": false, "reason": null}}Verify every message before trusting it:
- Read
tandv1fromX-9211SMS-Signature. - Compute
HMAC-SHA256(secret, t + "." + raw_request_body)as hex and compare it withv1using a constant-time comparison. - Reject the message if
tis more than 5 minutes from your clock. - Ignore a
X-9211SMS-Deliveryid you have already processed (retries reuse the same id).
import crypto from "node:crypto";
function verify(secret, header, rawBody) {
const m = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header || "");
if (!m || Math.abs(Date.now() / 1000 - Number(m[1])) > 300) return false;
const expected = crypto.createHmac("sha256", secret).update(`${m[1]}.${rawBody}`).digest("hex");
return crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(m[2]));
}function verify($secret, $header, $rawBody) {
if (!preg_match('/^t=(\d+),v1=([0-9a-f]{64})$/', $header ?? '', $m) || abs(time() - (int)$m[1]) > 300) return false;
return hash_equals(hash_hmac('sha256', $m[1] . '.' . $rawBody, $secret), $m[2]);
}Answer with any 2xx within 10 seconds. Otherwise we retry after about 1 min, 5 min, 15 min, 1 hour and 4 hours (6 attempts in total). Redirects are not followed. Webhooks are a convenience — always keep polling the order status as the source of truth.
Security tips
- Never put your key in a browser, app or public code.
- Use one key per program and revoke keys you no longer use.
- Limit keys to your server's IP address where possible.
Getting started
- Sign in to your existing 9211SMS account and open API Dashboard.
- Request API access. An administrator must approve it; suspended, banned or locked accounts cannot use the API.
- Create and securely store a named API key. Use one key per integration.
- Add funds to the API wallet via the dashboard top-up, not the website wallet.
- Read balance, countries, services and prices. Choose actual codes from the catalog, not a name or dialling code.
- Submit a REST purchase with a persistent unique Idempotency-Key, save its public
id, and poll that order for OTP. - Stop polling on a terminal status. After OTP, finish the order or let its two-minute completion grace elapse.
API approval does not enable the platform. API, purchase, top-up and webhook switches are independent: approval alone switches none of them on — each is controlled separately, so check the current switch state before integrating.
API versioning
The implemented external API version is v1, in /api/v1. Compatibility actions also live under v1. No v2 endpoint or alternate version header is implemented. Breaking changes should use a new version; consult this changelog before updating integrations.
API key generation and revocation
Key creation, revocation and regeneration are customer-dashboard actions, not external v1 endpoints. Approved customers can maintain up to five active keys. The key is shown once; it cannot be recovered. Only a prefix is displayed later. Regeneration creates a replacement before revoking the old key; if revocation fails, explicitly revoke the old key. Revoking a key prevents new authentication but does not cancel its orders. Orders belong to your account and can be accessed with another valid key on that account. Administrator-set IP restrictions apply to authentication.
Wallet transactions and top-ups
Wallet transactions and Volzix top-up initiation are available in the authenticated API Dashboard → API wallet, not through public API-key endpoints. There is no /api/v1/transactions or /api/v1/topups endpoint.
API wallet deposits use the existing JazzCash, EasyPaisa and OneQR integration. Minimum base top-up is PKR 100. The Deposit Processing Fee is 4%: a PKR 100 base deposit costs PKR 104, while only PKR 100 reaches the API wallet. Credit occurs only after payment verification and only once per payment reference. No automatic transfers between website/API wallets. Frozen wallets refuse purchases. Refunds return the order price to the same API wallet, once, only when the safety rules allow it. Post-credit payment refunds are reviewed, not automatically deducted.
Active orders and pagination
There is no external GET /api/v1/orders list endpoint. Save the numeric public order ID from every purchase and use GET /api/v1/orders/{id} for an owned order. The dashboard's API Orders page provides account history and filtering using authenticated reads; it is not a new REST capability.
No external v1 endpoint implements page, limit, offset or cursor parameters. Catalog responses are complete arrays or compatibility maps; do not invent pagination fields. A catalog availability count may be null when unknown; compatibility count outputs use zero in that case.
Request and response schemas
REST authentication is required for all eight operations: approved/unlocked account, active key and allowed IP. No separate scope/permission header is implemented. Purchase also needs the API/purchase switches and an unfrozen wallet with sufficient funds. Order operations are owner-only. The request bodies for cancel and finish are unused; no body is required.
The REST order schema is:
{"id":1042,"status":"waiting","under_review":false,"service":"wa","country":"22","phone":"+919876543210","price_pkr":55.5,"otp_code":null,"created_at":"2026-11-10T12:00:00Z","expires_at":"2026-11-10T12:20:00Z","refunded":false,"reason":null}phone, otp_code, expires_at and reason may be null. Status is one of purchasing, waiting, otp_received, completed, cancelled, expired, failed or under_review. REST orders do not include a currency field; all order prices are PKR. reason is only wrong_country or null; internal review reasons are private. Error data may contain the current order or price_pkr for a price-ceiling refusal. Treat this as an optional field.
Catalog rows can change between a price read and purchase. Send max_price to protect a spending ceiling. Catalog reads use synced data cached up to 60 seconds per server instance; they do not reserve supplier inventory.
Complete integration tutorial
Use the endpoint reference's cURL, PHP, server-side JavaScript and Python examples below. Example response payloads illustrate the implemented schema; they are not live stock, prices or transactions. The Playground alone displays actual server responses.
Maintain a local record mapping your business order to the API key identity + idempotency reference + returned public order ID. Never generate a new reference just because a request timed out. Retry the same service/country/reference with the same key, then inspect replay and status. Do not switch keys during a retry. An under-review order is still charged and needs resolution; do not replace it with another purchase automatically.
On OTP receipt, securely deliver the code to your customer and stop treating the order as refundable. Cancel only while waiting and without a code. early_cancel_denied means retry later, not refund success. try_again means confirmation was not obtained, not that money was returned. After a confirmed cancel inspect refunded. Finish an OTP-bearing order to close it sooner; repeated finish on a completed order succeeds. Continue status polling even when webhooks are configured.
Webhook configuration and retries
Configure, pause, remove or rotate a signing secret in API Dashboard → Webhook. These are authenticated dashboard tools, not external v1 endpoints. Changing URL/secret affects pending deliveries. Both global and customer enablement are needed. Secrets are shown once; store them separately from API keys. Check the raw body before JSON parsing or trusting the OTP. Deduplicate the stable delivery ID in persistent storage in the same transaction as handling the event; a duplicate can receive 2xx without doing the work again. Retry timestamps/signatures change but delivery IDs stay stable.
Six total attempts are made. Ordinary failure delays are 1 minute, 5 minutes, 15 minutes, 1 hour and 4 hours. Interrupted sending leases are recovered after two minutes and rescheduled after one minute. Any 2xx acknowledges delivery; return within 10 seconds. Redirects fail. Webhooks require a public HTTPS domain. Domain validation does not prove network isolation; administrators must restrict private/internal egress before enabling outgoing webhooks.
Python verification example:
import hashlib, hmac, re, time
def verify(secret, header, raw_body):
match = re.fullmatch(r't=(\d{1,12}),v1=([0-9a-f]{64})', header or '')
if not match or abs(time.time() - int(match[1])) > 300:
return False
signed = match[1].encode() + b'.' + raw_body # raw_body is bytes
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, match[2])Keep your system clock synchronized. Reject invalid/stale signatures without logging the raw payload, key or secret. Verification alone does not deduplicate event handling.
Troubleshooting and FAQ
Why does the API return 404? The API switch may be off. Disabled endpoints deliberately return plain-text Not Found. A missing/unowned order also returns 404 but with the JSON not_found error after authentication. Production deployment/routing must be verified separately.
Why BAD_KEY or invalid_key with a valid key? Check revocation, IP restrictions, Bearer syntax and the 30-invalid-attempts/IP minute window. Do not log the full key. Account refusal is separate from key refusal.
Why are purchases refused after approval? Approval does not enable API/purchases. Check wallet frozen state, sufficient API balance, active-order limits, supplier availability and the returned error.
Why is my website balance not available? API wallet and website wallet are independent. No transfers are performed.
Why no number with HTTP 201? Inspect the order: a clear supplier failure may already be refunded; unclear outcomes stay under review. Do not infer success from HTTP alone.
Why is a cancelled number not refunded yet? Cancellation must be confirmed and OTP rechecked. Pending or refused cancellation is not a refund. Never retry with a new purchase reference to resolve this.
Can I use an API key in my frontend? No. Keep integration keys on your own server. The authenticated 9211SMS Playground is a deliberate, temporary first-party testing exception; it stores no key and cannot place purchases or call order providers in this phase.
What about CORS? No cross-origin browser API contract is implemented. Use server-to-server integrations. Playground targets the current origin only.
What should I send support? Timestamp, public order ID, endpoint, HTTP status and error code. Never send keys, signing secrets or raw OTP payloads.
API changelog
v1 documentation — 11 November 2026
Public searchable reference, four-language REST examples, shared navigation, safe read-only Playground and explicit dashboard-only capability notes. This is a development documentation update, not a production release or API activation.
v1 platform implementation — development stages 1–6
API approval and keys, separate PKR wallet, read endpoints, invalid-key IP protection, atomic purchases/idempotency, OTP/cancel/finish operations, wrong-country cancellation protection, optional price overrides and signed webhook queue. All activation, real purchase testing and VPS deployment remain separately gated.