otpwatch handler_api.php recipes
Get API key

handler_api.php reference

One endpoint, GET only, the method name in action. Most replies are plain strings; five actions answer in JSON. Below is each action with its parameters, an example and every answer it can give.

Get an API key Opens sign-up on SimAggregator, the marketplace this API belongs to. Key in the dashboard, balance in USD.

Request shape

every call
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
GET https://sim-aggregator.org/stubs/handler_api.php?action=<method>&api_key=<key>&<params>
  • GET only. Parameters go in the query string. There is no request body and no auth header.
  • Errors live in the body. An unknown key answers BAD_KEY with HTTP 200 and text/plain. Read the body first; treat a non-2xx status as a transport problem, not an API answer.
  • Two reply formats. getPrices, getCountries, getServicesList, getCurrentActivationsList and a successful getNumberV2 return JSON. Everything else, including every refusal, is a short string like ACCESS_BALANCE:12.50 or NO_NUMBERS.
  • Split on the first colon only. In STATUS_OK:<code> the code is everything after the first :. Keep it a string: a code like 004821 loses its zeros as an integer.
  • Numbers come without +. 447700900123 is the full international number. Add the plus yourself if a form needs it.
  • Money is US dollars. getNumberV2 reports currency: 840, the ISO 4217 numeric code for USD.
  • Limits: 600 requests per minute per key, and once every 2 to 5 seconds per activation for status polling.

Summary

actionWhat it doesRequiredOptionalSuccess reply
getPricesprice and stock per country and servicecountry, serviceJSON
getCountriescountry referenceJSON
getServicesListservice referencecountryJSON
getBalanceaccount balanceACCESS_BALANCE:<amount>
getNumberorder a numbercountry, serviceduration, maxPriceACCESS_NUMBER:<id>:<number>
getNumberV2order, JSON replycountry, serviceduration, maxPriceJSON
getStatusstate of one activationidSTATUS_*
getCurrentActivationsListopen orders for this keyJSON array
setStatusanother code, finish or cancelid, statusACCESS_*

Every action also needs action and api_key.

Selling numbers to other people on top of these calls? Two pages put them together: a Telegram number bot with full code, and an OTP number panel with markup and price-list code.

getPrices

Price and stock for a country, a service, or both. Without filters you get the whole price list, which is large; ask for what you need.

request
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=getPrices&api_key=KEY&country=16&service=tg
reply
// handler_api reference: https://otpwatch.com/handler-api
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
{ "16": { "tg": { "cost": 1.38, "count": 280 } } }

cost is in USD per one-off activation, count is how many numbers are free. Possible refusals: BAD_COUNTRY, BAD_SERVICE, BAD_KEY. Use it before an order to set maxPrice; price control shows the pattern.

getCountries

request
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=getCountries&api_key=KEY
reply
// handler_api reference: https://otpwatch.com/handler-api
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
{ "43": { "id": 43, "rus": "DE", "eng": "DE", "chn": "DE", "visible": 1, "retry": 1, "rent": 0, "multiService": 0 } }

The rus, eng and chn fields currently carry the two-letter ISO code, not a country name. That makes them a handy join key: map ISO codes to numeric ids once at startup instead of hardcoding ids. Country ids has the lookup code.

getServicesList

request
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=getServicesList&api_key=KEY&country=16
reply
// handler_api reference: https://otpwatch.com/handler-api
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
{ "status": "success", "services": [ { "code": "tg", "name": "Telegram" }, { "code": "wa", "name": "WhatsApp" } ] }

With country, the list narrows to services actually sold there. Refusals: BAD_COUNTRY, BAD_KEY.

getBalance

request → reply
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=getBalance&api_key=KEY
ACCESS_BALANCE:12.50

A string, not JSON: parse the part after the colon as a decimal. Each open order holds its price until it closes, so on big parallel runs budget with the balance minus the price of every order still open.

getNumber

request → reply
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=getNumber&api_key=KEY&country=16&service=tg&maxPrice=2
ACCESS_NUMBER:12345:447700900123
ParameterValues
countrynumeric country id, for example 16
serviceservice code, for example tg
durationactivation (default, one code), d1, d3, d7 to rent for 1, 3 or 7 days
maxPriceprice ceiling in USD; the order will not be placed above it

Keep the id: every later call needs it. Replies other than ACCESS_NUMBER:

ReplyMeaning
NO_BALANCEthe balance does not cover the order
NO_NUMBERSno free number for this pair right now (also the answer when a rental costs more than maxPrice)
WRONG_MAX_PRICE:<price>the price is above maxPrice; the tail is the lowest current price (one-off activations only)
BAD_MAX_PRICEmaxPrice is not a number above zero
BAD_COUNTRY, BAD_SERVICEunknown id or code; BAD_SERVICE also means the service has no such rental duration
BAD_DURATIONunknown duration value
CHANNEL_LIMITthe account has hit its limit of simultaneous orders
BAD_KEY, ERROR_APIkey rejected; unexpected server error

getNumberV2

Same parameters, same refusals as plain strings. Only the success reply changes:

reply
// handler_api reference: https://otpwatch.com/handler-api
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
{
  "activationId": 12345,
  "phoneNumber": "447700900123",
  "activationCost": 1.38,
  "currency": 840,
  "countryCode": "16",
  "canGetAnotherSms": "1",
  "activationTime": "2026-11-24 12:00:00",
  "activationOperator": "any"
}

activationTime is UTC. Since refusals are not JSON, check whether the body starts with { before parsing.

getStatus

request → reply
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=getStatus&api_key=KEY&id=12345
STATUS_OK:481920
ReplyMeaningNext move
STATUS_WAIT_CODEnumber issued, no SMS yetpoll again in 2 to 5 s
STATUS_OK:<code>code receiveduse it, then setStatus 6 or 3
STATUS_WAIT_RETRY:<code>waiting for the next code; tail is the previous onekeep polling
STATUS_CANCELactivation closed (cancelled or finished)stop polling
NO_ACTIVATIONunknown or already closed idstop polling

getCurrentActivationsList

reply
// handler_api reference: https://otpwatch.com/handler-api
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
[ { "numberid": 12345, "number": "447700900123", "status": 0 } ]

A flat array of this key's open orders: status 0 means waiting for a code, 3 means a code arrived. Closed orders are not listed; no open orders gives []. Rented numbers stay in the list until the rental ends. It is the cheapest way to find orders a crashed process left behind.

setStatus

request → reply
# handler_api reference: https://otpwatch.com/handler-api
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
?action=setStatus&api_key=KEY&id=12345&status=6
ACCESS_ACTIVATION
statusEffectSuccess reply
3ask for another code on the same numberACCESS_RETRY_GET
6finish: the code was acceptedACCESS_ACTIVATION
8cancel; the money returns to your balanceACCESS_CANCEL

Refusals: EARLY_CANCEL_DENIED (too early to cancel, repeat the request later; the docs give no time), BAD_STATUS (already closed, or a code was delivered so it cannot be cancelled), NO_ACTIVATION, BAD_KEY, ERROR_API.

One parser for every reply

Handle the string and JSON shapes in one place, so the rest of your code deals with values and named errors.

parse-reply.mjs
// handler_api reference: https://otpwatch.com/handler-api
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
// Turns any handler_api.php body into { ok, value } or { ok: false, error, detail }.
export function parseReply(action, body) {
  const text = body.trim();
  const json = text.startsWith("{") || text.startsWith("[");
  if (json) return { ok: true, value: JSON.parse(text) };
  const [head, ...rest] = text.split(":");
  const tail = rest.join(":");
  switch (head) {
    case "ACCESS_BALANCE": return { ok: true, value: Number(tail) };
    case "ACCESS_NUMBER": { const [id, phone] = tail.split(":"); return { ok: true, value: { id, phone } }; }
    case "STATUS_OK": return { ok: true, value: { state: "code", code: tail } };
    case "STATUS_WAIT_CODE": return { ok: true, value: { state: "waiting" } };
    case "STATUS_WAIT_RETRY": return { ok: true, value: { state: "waiting", previous: tail } };
    case "STATUS_CANCEL": return { ok: true, value: { state: "closed" } };
    case "ACCESS_ACTIVATION": case "ACCESS_CANCEL": case "ACCESS_RETRY_GET":
      return { ok: true, value: head };
    default: return { ok: false, error: head, detail: tail || null, action };
  }
}

What to do with each named error is on the error codes page.

ready to run it?

Nine actions, one key. Issue it in the dashboard and try getBalance first.

Get an API key

Install for your coding agent

terminal
# Agent skills index: https://otpwatch.com/.well-known/agent-skills/index.json
npx skills add https://otpwatch.com

Two skills: receiving an SMS code in your own app or test, and building a bot that sells numbers. Index: /.well-known/agent-skills/index.json

Updated