Integrate SMS Localhost into your application with our REST API.
Using WhatsApp? There's a dedicated guide. Connecting your number, agents, templates, campaigns and the WhatsApp REST APIAll API requests require an API key passed via the X-API-KEY header.
curl -H "X-API-KEY: your_api_key_here" \
https://sms.localhost.co.zw/api/v1/sms/history/import requests
headers = {"X-API-KEY": "your_api_key_here"}
response = requests.get(
"https://sms.localhost.co.zw/api/v1/sms/history/",
headers=headers
)
print(response.json())const response = await fetch(
"https://sms.localhost.co.zw/api/v1/sms/history/",
{ headers: { "X-API-KEY": "your_api_key_here" } }
);
const data = await response.json();
console.log(data);$ch = curl_init("https://sms.localhost.co.zw/api/v1/sms/history/");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"X-API-KEY: your_api_key_here"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://sms.localhost.co.zw/api/v1/sms/history/"))
.header("X-API-KEY", "your_api_key_here")
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString()
);
System.out.println(response.body());Generate API keys from your API Keys page in the dashboard.
/api/v1/auth/keys/
List active API keys or create a new one.
/api/v1/auth/keys/{key_id}/
Revoke an API key.
/api/v1/sms/send/
Send an SMS message.
curl -X POST https://sms.localhost.co.zw/api/v1/sms/send/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{"to": "0771234567", "sender": "MyBrand", "message": "Hello!"}'import requests
response = requests.post(
"https://sms.localhost.co.zw/api/v1/sms/send/",
headers={
"X-API-KEY": "your_api_key",
"Content-Type": "application/json",
},
json={
"to": "0771234567",
"sender": "MyBrand",
"message": "Hello!"
}
)
print(response.json())
# {"message_id": "...", "channel": "sms", "status": "sent", ...}const response = await fetch(
"https://sms.localhost.co.zw/api/v1/sms/send/",
{
method: "POST",
headers: {
"X-API-KEY": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
to: "0771234567",
sender: "MyBrand",
message: "Hello!",
}),
}
);
const data = await response.json();
console.log(data);
// {message_id: "...", channel: "sms", status: "sent", ...}$ch = curl_init("https://sms.localhost.co.zw/api/v1/sms/send/");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"X-API-KEY: your_api_key",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"to" => "0771234567",
"sender" => "MyBrand",
"message" => "Hello!",
]),
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$data = json_decode($response, true);
print_r($data);String json = """
{"to":"0771234567","sender":"MyBrand","message":"Hello!"}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://sms.localhost.co.zw/api/v1/sms/send/"))
.header("X-API-KEY", "your_api_key")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(
request, HttpResponse.BodyHandlers.ofString()
);
System.out.println(response.body());{
"message_id": "a1b2c3d4-...",
"channel": "sms",
"status": "sent",
"to": "0771234567",
"sender": "MyBrand",
"sms_credits": 142
}
/api/v1/sms/history/
Retrieve the last 100 sent messages.
curl https://sms.localhost.co.zw/api/v1/sms/history/ \
-H "X-API-KEY: your_api_key"import requests
response = requests.get(
"https://sms.localhost.co.zw/api/v1/sms/history/",
headers={"X-API-KEY": "your_api_key"}
)
messages = response.json()["messages"]
for msg in messages:
print(f"{msg['recipient']}: {msg['status']}")const response = await fetch(
"https://sms.localhost.co.zw/api/v1/sms/history/",
{ headers: { "X-API-KEY": "your_api_key" } }
);
const { messages } = await response.json();
messages.forEach(msg =>
console.log(`${msg.recipient}: ${msg.status}`)
);$ch = curl_init("https://sms.localhost.co.zw/api/v1/sms/history/");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-KEY: your_api_key"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch), true);
foreach ($data["messages"] as $msg) {
echo $msg["recipient"] . ": " . $msg["status"] . "\n";
}/api/v1/sms/senders/
List your Sender IDs or request a new one.
/api/v1/sms/testers/
List your verified tester numbers.
A sandbox key lets you build against /api/v1/sms/send/ without sending anything, spending credits or waiting for a sender ID. Create one on the API Keys page with Mode: Sandbox; it starts with test_ so you can tell it apart on sight.
400 in sandbox is a 400 in production."sandbox": true, "billed": 0, "credits_required" (what the live send would cost), the detected network, and a provider_message_id starting sandbox..sms.delivered webhook fires straight away. Send to a number ending in 0000 to get sms.failed instead. See Sandbox events for which endpoints receive them.X-Sub-Account as usual; the simulated send runs as that sub-account.403, so a key left in the wrong config can never spend real credits.Send to any number from your connected WhatsApp Business number. All four endpoints take to as a full international number (8–15 digits; + and spaces are ignored) and an optional client_reference (up to 64 characters): a retry with the same reference returns the original send with "duplicate": true instead of sending twice. A 200 means Meta accepted the message; use the status webhooks to learn whether it arrived. Inbox, agents and templates are covered in the WhatsApp guide.
/api/v1/whatsapp/send-template/
Send an approved template to any number, whether or not they have messaged you. This is the only way to reach someone whose 24-hour window is closed. One credit per message, except utility and service templates sent while the window is open, which are free because Meta does not charge for them either.
curl -X POST https://sms.localhost.co.zw/api/v1/whatsapp/send-template/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{"to": "+263771234567", "template_name": "incident_alert", "language": "en",
"components": [{"type": "body", "parameters": [{"type": "text", "text": "db-1"}]}],
"client_reference": "incident:41"}'import requests
response = requests.post(
"https://sms.localhost.co.zw/api/v1/whatsapp/send-template/",
headers={"X-API-KEY": "your_api_key"},
json={
"to": "+263771234567",
"template_name": "incident_alert",
"language": "en",
"components": [{"type": "body",
"parameters": [{"type": "text", "text": "db-1"}]}],
"client_reference": "incident:41",
},
)
print(response.json()){
"message_id": "a1b2c3d4-...",
"provider_message_id": "wamid...",
"status": "sent",
"to": "263771234567",
"channel": "whatsapp",
"billed": 1,
"window": "closed",
"billing_reason": "...",
"sms_credits": 141
}
The next three are free-form: Meta allows them only while the customer's 24-hour window is open (they messaged you in the last 24 hours), and charges nothing for them there, so they always return "billed": 0. A closed window — or a number that has never messaged you — is refused with 409 and "window": "closed"; send a template instead. A body Meta would reject is a 400 whose error names the field.
/api/v1/whatsapp/send-text/
Plain text into an open window — typically the reply that closes a loop after someone taps a button.
curl -X POST https://sms.localhost.co.zw/api/v1/whatsapp/send-text/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{"to": "+263771234567", "body": "Acknowledged.", "client_reference": "ack:41"}'{
"message_id": "a1b2c3d4-...",
"provider_message_id": "wamid...",
"status": "sent",
"to": "263771234567",
"channel": "whatsapp",
"billed": 0,
"window": "open",
"billing_reason": "free inside the 24h service window",
"sms_credits": 142
}
/api/v1/whatsapp/send-media/
An image, video, audio clip or document into an open window. Meta downloads the file from url, so it must be publicly reachable and https:// — a plain-http link could be swapped by anyone in between.
curl -X POST https://sms.localhost.co.zw/api/v1/whatsapp/send-media/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{"to": "+263771234567", "media_type": "image",
"url": "https://example.com/graph.png", "caption": "CPU, last hour",
"client_reference": "graph:41"}'/api/v1/whatsapp/send-interactive/
Reply buttons, a list, or a call-to-action link into an open window. interactive is Meta's own interactive object and is sent as given once it passes Meta's documented limits. Buttons are what let a reply come back with a machine-readable id: a tap arrives as a whatsapp.button_reply webhook carrying the button's id in button_id.
curl -X POST https://sms.localhost.co.zw/api/v1/whatsapp/send-interactive/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{"to": "+263771234567",
"interactive": {
"type": "button",
"body": {"text": "web-1 is down. Restart it?"},
"action": {"buttons": [
{"type": "reply", "reply": {"id": "restart:41", "title": "Restart"}},
{"type": "reply", "reply": {"id": "ignore:41", "title": "Ignore"}}
]}
},
"client_reference": "restart:41"}'A sandbox key lets you build and test against the four endpoints above without sending anything or spending credits. Create one on the API Keys page with Mode: Sandbox; it starts with test_ so you can tell it apart on sight.
400 in sandbox is a 400 in production. After that nothing reaches Meta, no credits are used, and no WhatsApp number needs to be connected. The window is always treated as open."billed": 0, "sandbox": true, and a provider_message_id starting sandbox..client_reference behaves as it does live: a retry returns the original response with "duplicate": true. References are remembered for 7 days.whatsapp.sent and whatsapp.delivered webhooks fire straight away. Send to a number ending in 0000 to get whatsapp.failed instead, with Meta's real error 131026. See Sandbox events for which endpoints receive them./api/v1/sms/send/. Every other endpoint (SMS history, contacts, campaigns, billing, the updates WebSocket) refuses it with 403 and {"error": "Sandbox keys can only be used with the SMS send and WhatsApp APIs"}, so a key left in the wrong config can never spend real credits./api/v1/contacts/
List contacts or create a new one.
# Create a contact
curl -X POST https://sms.localhost.co.zw/api/v1/contacts/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{"phone": "0771234567", "first_name": "John", "last_name": "Doe"}'import requests
# Create a contact
response = requests.post(
"https://sms.localhost.co.zw/api/v1/contacts/",
headers={
"X-API-KEY": "your_api_key",
"Content-Type": "application/json",
},
json={
"phone": "0771234567",
"first_name": "John",
"last_name": "Doe",
}
)
print(response.json())// Create a contact
const response = await fetch(
"https://sms.localhost.co.zw/api/v1/contacts/",
{
method: "POST",
headers: {
"X-API-KEY": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
phone: "0771234567",
first_name: "John",
last_name: "Doe",
}),
}
);
console.log(await response.json());// Create a contact
$ch = curl_init("https://sms.localhost.co.zw/api/v1/contacts/");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
"X-API-KEY: your_api_key",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"phone" => "0771234567",
"first_name" => "John",
"last_name" => "Doe",
]),
CURLOPT_RETURNTRANSFER => true,
]);
$data = json_decode(curl_exec($ch), true);/api/v1/contacts/{contact_id}/
Retrieve, update, or delete a single contact.
/api/v1/contacts/groups/
List contact groups or create a new one.
/api/v1/campaigns/
List campaigns or create a new one.
curl -X POST https://sms.localhost.co.zw/api/v1/campaigns/ \
-H "X-API-KEY: your_api_key" \
-H "Content-Type: application/json" \
-d '{
"name": "March Promo",
"message": "Hi {name}, enjoy 20% off this week!",
"sender_name": "MyBrand",
"group_id": "your_group_uuid"
}'import requests
response = requests.post(
"https://sms.localhost.co.zw/api/v1/campaigns/",
headers={
"X-API-KEY": "your_api_key",
"Content-Type": "application/json",
},
json={
"name": "March Promo",
"message": "Hi {name}, enjoy 20% off this week!",
"sender_name": "MyBrand",
"group_id": "your_group_uuid",
}
)
campaign = response.json()
print(f"Campaign created: {campaign['id']}")const response = await fetch(
"https://sms.localhost.co.zw/api/v1/campaigns/",
{
method: "POST",
headers: {
"X-API-KEY": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "March Promo",
message: "Hi {name}, enjoy 20% off this week!",
sender_name: "MyBrand",
group_id: "your_group_uuid",
}),
}
);
const campaign = await response.json();
console.log(`Campaign created: ${campaign.id}`);/api/v1/campaigns/{campaign_id}/send/
Launch a campaign for sending.
/api/v1/campaigns/{campaign_id}/pause/
Pause a running campaign.
/api/v1/campaigns/{campaign_id}/cancel/
Cancel a campaign.
/api/v1/billing/balance/
Get your current SMS credit balance.
curl https://sms.localhost.co.zw/api/v1/billing/balance/ \
-H "X-API-KEY: your_api_key"import requests
response = requests.get(
"https://sms.localhost.co.zw/api/v1/billing/balance/",
headers={"X-API-KEY": "your_api_key"}
)
data = response.json()
print(f"Credits remaining: {data['sms_credits']}")const response = await fetch(
"https://sms.localhost.co.zw/api/v1/billing/balance/",
{ headers: { "X-API-KEY": "your_api_key" } }
);
const data = await response.json();
console.log(`Credits remaining: ${data.sms_credits}`);$ch = curl_init("https://sms.localhost.co.zw/api/v1/billing/balance/");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-KEY: your_api_key"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$data = json_decode(curl_exec($ch), true);
echo "Credits remaining: " . $data["sms_credits"];/api/v1/billing/transactions/
View your transaction history.
Approved resellers manage sub-accounts — one per client, each with its own credit balance, API keys, sender IDs and history. Credits are moved from your pool into a sub-account and can be pulled back; nothing here is priced in money. Everything below is called with your reseller key. Not a reseller yet? Apply from the dashboard under Reseller.
any endpoint
with header X-Sub-Account
Act as one of your sub-accounts with your own key. Pass our sub-account id or the external_ref you gave it. The call then uses that sub-account's credits, sender IDs and history — on /sms/send/, /sms/history/, /billing/balance/, contacts, campaigns, everything. Alternatively, issue the sub-account its own key (below) and call without the header.
curl -X POST https://sms.localhost.co.zw/api/v1/sms/send/ \
-H "X-API-KEY: your_reseller_key" \
-H "X-Sub-Account: acme-pharmacy" \
-H "Content-Type: application/json" \
-d '{"to": "0771234567", "sender": "MyBrand", "message": "Hello!"}'import requests
requests.post(
"https://sms.localhost.co.zw/api/v1/sms/send/",
headers={
"X-API-KEY": "your_reseller_key",
"X-Sub-Account": "acme-pharmacy", # your external_ref or our id
},
json={"to": "0771234567", "sender": "MyBrand", "message": "Hello!"},
)/api/v1/reseller/summary/
Your pool balance, total held by sub-accounts, and every sub-account with its balance and 30-day send count.
/api/v1/reseller/sub-accounts/
List sub-accounts (?include_inactive=1 for deactivated ones), or create one.
curl -X POST https://sms.localhost.co.zw/api/v1/reseller/sub-accounts/ \
-H "X-API-KEY: your_reseller_key" \
-H "Content-Type: application/json" \
-d '{"name": "Acme Pharmacy", "external_ref": "acme-pharmacy"}'
# 201
{"sub_account": {"id": "…", "name": "Acme Pharmacy", "external_ref": "acme-pharmacy",
"sms_credits": 0, "is_active": true, "created_at": "…", "sent_last_30_days": 0}}/api/v1/reseller/sub-accounts/{id_or_ref}/
Read one sub-account (with its active keys), rename it or change its external_ref, or deactivate it — which returns its remaining credits to your pool and revokes its keys. History is kept.
/api/v1/reseller/sub-accounts/{id_or_ref}/allocate/
Move credits from your pool into the sub-account. Fails with 402 if your pool cannot cover it; nothing moves in that case.
curl -X POST https://sms.localhost.co.zw/api/v1/reseller/sub-accounts/acme-pharmacy/allocate/ \
-H "X-API-KEY: your_reseller_key" \
-H "Content-Type: application/json" \
-d '{"credits": 500}'
# 200
{"allocated": 500, "sub_account": {"…": "…", "sms_credits": 500}, "pool_credits": 9500}/api/v1/reseller/sub-accounts/{id_or_ref}/reclaim/
Move credits back from the sub-account into your pool. 409 if it holds fewer than asked.
/api/v1/reseller/sub-accounts/{id_or_ref}/keys/
List or create API keys bound to the sub-account. A key made here can only act as that sub-account — hand it to your client or keep it in your platform. The full key is returned once. Revoke with DELETE …/keys/{key_id}/.
/api/v1/reseller/sub-accounts/{id_or_ref}/transactions/
The sub-account's credit ledger — allocations in, sends out — last 100 rows, credits only.
/api/v1/reseller/sub-accounts/{id_or_ref}/sender-ids/
List every sender ID the sub-account holds, or order a new one for it. You collect any fee from your client; we charge nothing for the order and record the fee you tell us, so you can reconcile. The name then goes through the usual approval. Sending the same reference again for the same name returns the existing order with 200.
curl -X POST https://sms.localhost.co.zw/api/v1/reseller/sub-accounts/acme-pharmacy/sender-ids/ \
-H "X-API-KEY: your_reseller_key" \
-H "Content-Type: application/json" \
-d '{"sender_name": "AcmePharm", "business_name": "Acme Pharmacy (Pvt) Ltd",
"purpose": "Prescription reminders", "sample_message": "Your prescription is ready. Acme Pharmacy.",
"reference": "order-1042", "fee": {"amount": "5.00", "currency": "USD"}}'
# 201
{"sender_id": {"id": "…", "sender_name": "AcmePharm", "status": "pending", "note": "", "suggestion": "",
"reference": "order-1042", "fee": {"amount": "5.00", "currency": "USD"},
"sub_account": {"id": "…", "external_ref": "acme-pharmacy"},
"created_at": "…", "decided_at": null}}/api/v1/reseller/sender-ids/
Every sender ID you have ordered, across all sub-accounts, newest first. Filter with ?status=pending|approved|rejected|frozen and ?since= an ISO-8601 date or time (when the order was placed).
LinksAPI automatically shortens links in your outgoing messages using branded
rerout.co short links. Shorter links use fewer 160-character SMS segments — so you
spend fewer credits — and every link gets click analytics. It applies to SMS sent from the
dashboard, the Send API, and campaigns, plus free-text WhatsApp messages.
There is nothing to call — it runs server-side at send time. Turn it on per organization at
LinksAPI in your dashboard; from then on any
https:// link in your message is replaced automatically before it is sent and billed.
In per-recipient mode you can enable one-time links: each link stops redirecting after its first click — ideal for single-use survey or verification links. The first click is served, then the link is deactivated automatically.
Total clicks plus top countries and referrers are shown for every link on your LinksAPI page. Click data is aggregated and never exposes recipients' raw IP addresses.
Check the live delivery status of Zimbabwean mobile network operators (NetOne, Econet, Telecel) so your application can react to carrier-side incidents — e.g. pause sends, switch fallback routes, or surface a banner to your own users. You can also subscribe to webhook events that fire the moment a status changes (see Webhooks).
/api/v1/status/
Returns the current status for every MNO. Possible state values: operational, degraded, outage, maintenance.
curl https://sms.localhost.co.zw/api/v1/status/ \
-H "X-API-KEY: your_api_key"import requests
statuses = requests.get(
"https://sms.localhost.co.zw/api/v1/status/",
headers={"X-API-KEY": "your_api_key"},
).json()
for s in statuses:
if s["state"] != "operational":
print(f"{s['mno_display']} is {s['state']}: {s['note']}")const res = await fetch(
"https://sms.localhost.co.zw/api/v1/status/",
{ headers: { "X-API-KEY": "your_api_key" } }
);
const statuses = await res.json();
statuses
.filter(s => s.state !== "operational")
.forEach(s => console.warn(`${s.mno_display}: ${s.state}`));Sample response
[
{"mno":"netone", "mno_display":"NetOne", "state":"outage", "state_display":"Outage", "note":"NetOne core network issue, ETA 2h", "updated_at":"2026-05-12T10:00:00Z"},
{"mno":"econet", "mno_display":"Econet", "state":"operational", "state_display":"Operational", "note":"", "updated_at":"2026-05-10T08:32:11Z"},
{"mno":"telecel", "mno_display":"Telecel", "state":"operational", "state_display":"Operational", "note":"", "updated_at":"2026-05-10T08:32:11Z"}
]
/api/v1/status/incidents/
History of state transitions. Optional query params: mno=netone|econet|telecel, limit=N (default 50, max 200). Incidents with ended_at: null are still in progress.
curl "https://sms.localhost.co.zw/api/v1/status/incidents/?mno=netone&limit=10" \
-H "X-API-KEY: your_api_key"Webhooks let us POST events to your server the instant they happen — no polling required. Register an endpoint at Settings → Webhooks, tick the events you care about, and copy the signing secret we generate (shown only once).
sms.delivered — an SMS reached its recipientsms.failed — an SMS failed deliverymno.status.changed — an MNO's delivery state changed (outage, degraded, recovered, maintenance)message.inbound — someone replied to youwhatsapp.button_reply — someone tapped a button on a WhatsApp messagewhatsapp.sent — Meta sent a WhatsApp message to the recipient's phonewhatsapp.delivered — a WhatsApp message reached its recipientwhatsapp.read — the recipient opened a WhatsApp message (only if they have read receipts on)whatsapp.failed — Meta could not deliver a WhatsApp message; carries error_code and error_detailsX-Webhook-Signature header (HMAC-SHA256 of the raw body, hex-encoded, using your secret).POST https://your-server.com/webhook
Content-Type: application/json
X-Webhook-Signature: 4f9c1a...e7
{
"event": "mno.status.changed",
"mno": "netone",
"previous_state": "operational",
"state": "outage",
"note": "NetOne core network issue, ETA 2h",
"incident_id": "5b6f2e4c-...",
"timestamp": "2026-05-12T10:00:00Z"
}
Sent when someone replies to you. A tap on a WhatsApp button arrives as whatsapp.button_reply and carries the button's payload in button_id, exactly as you set it — so a single-use token you put on a button comes back to you untouched.
POST https://your-server.com/webhook
Content-Type: application/json
X-Webhook-Signature: 8b2e70...c4
{
"event": "whatsapp.button_reply",
"from": "263771234567",
"to": "104512...",
"body": "Acknowledge",
"button_id": "ack:AbC-123_x",
"channel": "whatsapp",
"provider_message_id": "wamid...",
"timestamp": "2026-08-15T09:14:02Z"
}
All four whatsapp.* status events share one shape, with the error fields blank (and error_code null) unless the status is failed. message_id is the id the send endpoint returned, so you can match the event without storing Meta's id. Branch on error_code rather than the error title: the title cannot tell a number that is not on WhatsApp from one outside the 24-hour window, the code can.
Statuses only move forward. Meta reports them out of order and repeats them, so an event that would move a message backwards, or repeat one already sent, is dropped. You get each event at most once per message, but not necessarily every one: if read arrives before delivered, no delivered follows. failed is final.
POST https://your-server.com/webhook
Content-Type: application/json
X-Webhook-Signature: 1d93ab...02
{
"event": "whatsapp.failed",
"message_id": "a1b2c3d4-...",
"provider_message_id": "wamid...",
"recipient": "+263771234567",
"sender": "+263242000000",
"channel": "whatsapp",
"status": "failed",
"error": "Message undeliverable",
"error_code": 131026,
"error_details": "Unable to deliver message. Reasons can include: the recipient phone number is not a WhatsApp phone number.",
"timestamp": "2026-11-06T09:14:02Z"
}
Sends made with a sandbox key (SMS or WhatsApp) fire simulated status events. They are delivered only to webhooks with Also receive sandbox events ticked, and carry "sandbox": true in the body plus an X-Webhook-Sandbox: true header, so you can drop them before parsing. They are signed with your real secret — the opt-in exists so that whoever holds a sandbox key cannot send convincing failure events to a production endpoint that has never heard of sandbox mode.
Always verify X-Webhook-Signature against the raw request body — not a re-serialized JSON — using your webhook's secret:
import hmac, hashlib
from flask import Flask, request, abort
SECRET = b"your_webhook_secret"
app = Flask(__name__)
@app.post("/webhook")
def webhook():
expected = hmac.new(SECRET, request.get_data(), hashlib.sha256).hexdigest()
got = request.headers.get("X-Webhook-Signature", "")
if not hmac.compare_digest(expected, got):
abort(401)
event = request.get_json()
if event["event"] == "mno.status.changed" and event["state"] in ("outage", "degraded"):
pause_sends_for(event["mno"])
return "", 204const express = require("express");
const crypto = require("crypto");
const app = express();
const SECRET = "your_webhook_secret";
app.post("/webhook", express.raw({ type: "application/json" }), (req, res) => {
const expected = crypto.createHmac("sha256", SECRET).update(req.body).digest("hex");
const got = req.headers["x-webhook-signature"] || "";
if (!crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(got))) return res.sendStatus(401);
const event = JSON.parse(req.body.toString());
if (event.event === "mno.status.changed" && ["outage", "degraded"].includes(event.state)) {
pauseSendsFor(event.mno);
}
res.sendStatus(204);
});$secret = "your_webhook_secret";
$body = file_get_contents("php://input");
$expected = hash_hmac("sha256", $body, $secret);
$got = $_SERVER["HTTP_X_WEBHOOK_SIGNATURE"] ?? "";
if (!hash_equals($expected, $got)) { http_response_code(401); exit; }
$event = json_decode($body, true);
if ($event["event"] === "mno.status.changed" && in_array($event["state"], ["outage", "degraded"])) {
pause_sends_for($event["mno"]);
}
http_response_code(204);All errors return a JSON object with an error key.
{"error": "Insufficient SMS credits."}