otpwatch handler_api.php recipes
Get API key

Real SMS codes in your test suite, in ten lines

Order a number on a real SIM, wait for the code with getStatus, close the order. Everything here is a working recipe for that loop: clients in five languages, Playwright, Cypress and Selenium patterns, CI, and the reference tables you keep reaching for.

Get an API key Keys are issued in the SimAggregator dashboard. Balance in USD, top-up with USDT TRC-20.

The whole protocol in three calls

Every flow on this site, from a nightly regression run to a bot that sells numbers, is the same loop over one GET endpoint, https://sim-aggregator.org/stubs/handler_api.php. The method goes in action, your key goes in api_key.

Order a number

getNumber with a service code and a country id. The reply is a plain string, ACCESS_NUMBER:<id>:<number>. The price is put on hold on your balance, not charged yet.

Wait for the SMS

Call getStatus with that id every 3 seconds or so. You get STATUS_WAIT_CODE until the message lands, then STATUS_OK:<code>.

Close the order

setStatus with status=6 when the code did its job. If the code never came, status=8 cancels and the hold goes back to your balance. Closing explicitly frees the slot for the next order.

Ten lines, five languages

Bare on purpose: no error handling, no timeout. If getNumber answers NO_BALANCE instead of a number, these scripts crash on the split, which is fine for a first run and wrong for anything else. The language pages have the production versions.

.env.example
# handler_api reference: https://otpwatch.com/
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
SMS_API_BASE_URL=https://sim-aggregator.org/stubs/handler_api.php
# Key from the SimAggregator dashboard: https://otpwatch.com/key
SMS_API_KEY=
otp.py
# handler_api reference: https://otpwatch.com/
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
import os, time, requests

API = os.getenv("SMS_API_BASE_URL", "https://sim-aggregator.org/stubs/handler_api.php")
def sms(action, **p):
    return requests.get(API, params={"action": action, "api_key": os.environ["SMS_API_KEY"], **p}, timeout=30).text

_, act_id, phone = sms("getNumber", service="tg", country=16).split(":")  # ACCESS_NUMBER:id:number
print("send the code to +" + phone)
while not (status := sms("getStatus", id=act_id)).startswith("STATUS_OK"):
    time.sleep(3)
print("code:", status.split(":", 1)[1])
sms("setStatus", id=act_id, status=6)
otp.mjs
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
const API = process.env.SMS_API_BASE_URL ?? "https://sim-aggregator.org/stubs/handler_api.php";
const sms = async (action, p = {}) =>
  (await fetch(`${API}?${new URLSearchParams({ action, api_key: process.env.SMS_API_KEY, ...p })}`)).text();

const [, id, phone] = (await sms("getNumber", { service: "tg", country: "16" })).split(":");
console.log(`send the code to +${phone}`);
let status;
while (!(status = await sms("getStatus", { id })).startsWith("STATUS_OK"))
  await new Promise((r) => setTimeout(r, 3000));
console.log("code:", status.split(":")[1]);
await sms("setStatus", { id, status: "6" });
otp.cs
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
// .NET 10 runs a single file directly: dotnet run otp.cs
using var http = new HttpClient();
var api = Environment.GetEnvironmentVariable("SMS_API_BASE_URL") ?? "https://sim-aggregator.org/stubs/handler_api.php";
var key = Uri.EscapeDataString(Environment.GetEnvironmentVariable("SMS_API_KEY") ?? "");
async Task<string> Sms(string query) => await http.GetStringAsync($"{api}?api_key={key}&{query}");

var parts = (await Sms("action=getNumber&service=tg&country=16")).Split(':'); // ACCESS_NUMBER:id:number
Console.WriteLine($"send the code to +{parts[2]}");
string status;
while (!(status = await Sms($"action=getStatus&id={parts[1]}")).StartsWith("STATUS_OK"))
    await Task.Delay(3000);
Console.WriteLine($"code: {status.Split(':', 2)[1]}");
await Sms($"action=setStatus&id={parts[1]}&status=6");
otp.php
<?php
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner
$api = getenv("SMS_API_BASE_URL") ?: "https://sim-aggregator.org/stubs/handler_api.php";
$sms = fn(array $p) => trim(file_get_contents($api . "?" . http_build_query($p + ["api_key" => getenv("SMS_API_KEY")])));

[, $id, $phone] = explode(":", $sms(["action" => "getNumber", "service" => "tg", "country" => 16]));
echo "send the code to +$phone\n";
while (!str_starts_with($status = $sms(["action" => "getStatus", "id" => $id]), "STATUS_OK")) {
    sleep(3);
}
echo "code: " . explode(":", $status, 2)[1] . "\n";
$sms(["action" => "setStatus", "id" => $id, "status" => 6]);
main.go
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/partner

package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
	"os"
	"strings"
	"time"
)

func sms(p url.Values) string {
	p.Set("api_key", os.Getenv("SMS_API_KEY"))
	base := os.Getenv("SMS_API_BASE_URL")
	if base == "" {
		base = "https://sim-aggregator.org/stubs/handler_api.php"
	}
	resp, err := http.Get(base + "?" + p.Encode())
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	b, _ := io.ReadAll(resp.Body)
	return strings.TrimSpace(string(b))
}

func main() {
	parts := strings.Split(sms(url.Values{"action": {"getNumber"}, "service": {"tg"}, "country": {"16"}}), ":")
	fmt.Println("send the code to +" + parts[2])
	status := ""
	for !strings.HasPrefix(status, "STATUS_OK") {
		time.Sleep(3 * time.Second)
		status = sms(url.Values{"action": {"getStatus"}, "id": {parts[1]}})
	}
	fmt.Println("code:", strings.SplitN(status, ":", 2)[1])
	sms(url.Values{"action": {"setStatus"}, "id": {parts[1]}, "status": {"6"}})
}

tg is the Telegram service code and 16 is the United Kingdom. Swap in the pair you need from service codes and country ids. The number comes back without a leading +, which is why every snippet adds one before printing.

What a number costs right now

The lowest current price for each service that has a code in the public docs, across all countries in stock. Service codes has the cheapest countries per service.

Serviceservice=FromCountry
WhatsAppwa$0.1875Indonesia
Telegramtg$0.1875Indonesia
VKvk$0.025Indonesia
Googlego$0.025Indonesia
Facebookfb$0.0125Indonesia
TikToklf$0.0125Indonesia
Discordds$0.0125Indonesia
OpenAIdr$0.025Argentina
Claudeacz$0.0213United Kingdom

“From” price per one-off activation, USD, read from public SimAggregator pages on (UTC). Prices move; getPrices gives the live figure.

Pick the page for the job

You areStart here
Writing a client from scratchPython, Node.js, C#, PHP, Go
Testing a sign-up or login flow end to endPlaywright, Cypress, Selenium
Running those tests on a scheduleGitHub Actions and CI
Building a bot that sells numbers in TelegramTelegram number bot: Python and Node.js
Running a panel or website that resells numbersOTP number panel: markup and rules
Moving a bot that already speaks this protocolMigrate by changing the base URL
Keeping one test account for a weekRent a number over the API
Watching the budgetPrice control, cancel and refund
Letting an AI agent run your QA flowPhone verification for agent-driven tests

Limits worth knowing before the first run

  • 600 requests per minute per key. Every action counts, not only getStatus. Poll each activation once every 2 to 5 seconds.
  • The activation window is set per service in the catalog. Right now it is one hour for every service. When it runs out without an SMS, the order closes and the money returns to your balance by itself.
  • A cancel can come too early. setStatus with 8 can answer EARLY_CANCEL_DENIED: too early to cancel, repeat the request later. The docs give no time, so retry with a pause and a cap on attempts.
  • Refunds go to the internal balance, never back to a wallet.
  • Prices and balance are in US dollars. Top-up is USDT on the TRON network only: here is the funding walkthrough.

Whose endpoint this is

Every recipe here talks to one service, SimAggregator (sim-aggregator.org), and otpwatch only documents it. Numbers on that marketplace come from suppliers: the SMS your loop polls for lands on a SIM card in a supplier's own equipment before it reaches getStatus. The public API speaks the handler_api protocol, a single GET endpoint at /stubs/handler_api.php laid out like the popular marketplaces, so a client written for that format needs a new base URL and key. An activation that ends with no SMS puts the money back on the balance without a refund request, and the balance is funded in USDT TRC-20. All four points are stated on the SimAggregator home page (sim-aggregator.org/en, the FAQ and the API block), which we checked on 24 Nov 2026.

ready to run it?

One key, one base URL, nine actions. The rest of this site is detail.

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 · prices from the 24 Nov 2026 snapshot