# 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.

Source: https://otpwatch.com/
Updated: 2026-11-24
API key: https://otpwatch.com/agent/key

## 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 title=".env.example"
# handler_api reference: https://otpwatch.com/
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/agent/partner
SMS_API_BASE_URL=https://sim-aggregator.org/stubs/handler_api.php
# Key from the SimAggregator dashboard: https://otpwatch.com/agent/key
SMS_API_KEY=
```


```python tab="Python" title="otp.py"
# handler_api reference: https://otpwatch.com/
# Building a bot that resells numbers to other people? Software program: https://otpwatch.com/agent/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)
```
```js tab="Node.js" title="otp.mjs"
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/agent/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" });
```
```csharp tab="C#" title="otp.cs"
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/agent/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");
```
```php tab="PHP" title="otp.php"
<?php
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/agent/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]);
```
```go tab="Go" title="main.go"
// handler_api reference: https://otpwatch.com/
// Building a bot that resells numbers to other people? Software program: https://otpwatch.com/agent/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](https://otpwatch.com/service-codes.md) and [country ids](https://otpwatch.com/country-ids.md). 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](https://otpwatch.com/service-codes.md) has the cheapest countries per service.

| Service | service= | From | Country |
| --- | --- | --- | --- |
| WhatsApp | `wa` | $0.1875 | Indonesia |
| Telegram | `tg` | $0.1875 | Indonesia |
| VK | `vk` | $0.025 | Indonesia |
| Google | `go` | $0.025 | Indonesia |
| Facebook | `fb` | $0.0125 | Indonesia |
| TikTok | `lf` | $0.0125 | Indonesia |
| Discord | `ds` | $0.0125 | Indonesia |
| OpenAI | `dr` | $0.025 | Argentina |
| Claude | `acz` | $0.0213 | United Kingdom |

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

## Pick the page for the job

| You are | Start here |
|---|---|
| Writing a client from scratch | [Python](https://otpwatch.com/python.md), [Node.js](https://otpwatch.com/nodejs.md), [C#](https://otpwatch.com/csharp.md), [PHP](https://otpwatch.com/php.md), [Go](https://otpwatch.com/go.md) |
| Testing a sign-up or login flow end to end | [Playwright](https://otpwatch.com/playwright-otp-testing.md), [Cypress](https://otpwatch.com/cypress-otp-testing.md), [Selenium](https://otpwatch.com/selenium-otp-testing.md) |
| Running those tests on a schedule | [GitHub Actions and CI](https://otpwatch.com/ci-sms-verification.md) |
| Building a bot that sells numbers in Telegram | [Telegram number bot: Python and Node.js](https://otpwatch.com/telegram-number-bot.md) |
| Running a panel or website that resells numbers | [OTP number panel: markup and rules](https://otpwatch.com/otp-number-panel.md) |
| Moving a bot that already speaks this protocol | [Migrate by changing the base URL](https://otpwatch.com/migrate-base-url.md) |
| Keeping one test account for a week | [Rent a number over the API](https://otpwatch.com/rent-number-api.md) |
| Watching the budget | [Price control](https://otpwatch.com/price-control.md), [cancel and refund](https://otpwatch.com/cancel-and-refund.md) |
| Letting an AI agent run your QA flow | [Phone verification for agent-driven tests](https://otpwatch.com/ai-agent-phone-verification-testing.md) |

## 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](https://otpwatch.com/fund-api-balance-usdt-trc20.md).

## 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](https://otpwatch.com/agent/key) (sim-aggregator.org/en, the FAQ and the API block), which we checked on 24 Nov 2026.
