Webhooks
Tested on 28 November 2026 against a local build of the current Simline API with a simulated test phone. The three receivers below (Node 22 with built-in modules only, Python 3.13 with Flask 3.1, PHP 8.3) each accepted real events and rejected a forged signature with 401.
Give Simline a URL and every new text, delivery report and phone going on or offline becomes a signed POST to it. Deliveries are retried for about 22 hours, logged, and can be replayed.
Create an endpoint
Section titled “Create an endpoint”In the dashboard: Developers → Webhooks → Add endpoint. Pick the events (default: all) and the phones (default: every phone, including ones you pair later).
Or with an API key that has both the send and read scopes:
curl https://api.simline.dev/v1/webhooks \ -H "Authorization: Bearer $SIMLINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"url": "https://example.com/simline/hook", "events": ["message.received", "message.failed"]}'The answer includes secret (whsec_…). It’s shown once: store it with your app’s other secrets.
https://only, on a public host: no IP addresses, nolocalhost, no internal names (.local,.internal, single-label hosts). Simline also checks the address the host resolves to, at save time and before every attempt, and never calls private, loopback or reserved addresses.- Up to 20 endpoints per workspace.
deviceIdslimits an endpoint to events from some phones.
Events
Section titled “Events”| Event | When |
|---|---|
message.received |
A new text arrived on one of your phones. |
message.sent |
Every part of an outbound text left the phone. |
message.delivered |
The carrier confirmed delivery of every part. |
message.failed |
An outbound text failed; data.errorCode says why. |
device.online |
A phone connected for the first time, or came back after being reported offline. |
device.offline |
A phone became unreachable (it didn’t answer a wake-up within 5 minutes, or missed two check-ins in a row), or was unpaired. |
webhook.test |
Only from the Send test event button or POST /v1/webhooks/{id}/test. |
There’s one event per message, attempt and state: a text that fails and then succeeds on a second attempt gives you both. A phone that merely sleeps (Android paused the app, but Simline can wake it) sends nothing; see Phone reliability.
What arrives
Section titled “What arrives”POST /simline/hook HTTP/1.1Content-Type: application/jsonSimline-Event-Id: evt_cbb3ca99be3d5358e027f561a3c72896Simline-Event-Type: message.receivedSimline-Delivery-Id: whd_AuER0XoaWoMaTw3bPa7KoQSimline-Attempt: 1Simline-Signature: t=1795857276,v1=5f2c…{ "id": "evt_cbb3ca99be3d5358e027f561a3c72896", "type": "message.received", "createdAt": "2026-11-28T09:14:36.438Z", "data": { "id": "msg_74e559d6d3b39531c3b4e054955a8461", "direction": "inbound", "status": "received", "finalStatus": true, "channel": "sms", "contact": "+33600000042", "body": "Bonjour, est-ce que la tarte aux pommes est prête ?", "deviceId": "dev_local", "simSlot": 1, "parts": null, "attempt": 1, "errorCode": null, "idempotencyKey": null, "apiKeyId": null, "userId": null, "agentId": null, "createdAt": "2026-11-28T09:14:35.414Z", "updatedAt": "2026-11-28T09:14:36.438Z", "sentAt": null, "deliveredAt": null, "readAt": null }}For message.* events, data is the message as GET /v1/messages/{id} returns it (without events) at the time of the event. For device.* events it’s smaller:
{"deviceId": "dev_local", "name": "Pixel 8", "status": "offline", "presence": "unreachable", "at": "2026-11-28T09:44:39.415Z"}presence is connected for online, and unreachable or unpaired for offline. The body is frozen per event, so retries and replays send identical bytes.
Verify the signature
Section titled “Verify the signature”Simline-Signature is t=<unix seconds>,v1=<hex>. The hex is HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with the whole secret string, whsec_ included.
- Read the raw body bytes. Don’t parse and re-serialize the JSON first: one changed space breaks the signature.
- Reject a timestamp more than 5 minutes from your clock, so an old request can’t be replayed at you.
- Compute the HMAC and compare in constant time.
- Accept if any
v1=matches: during a secret rotation there are two.
// receiver.mjs — Node 18+, no dependencies. SIMLINE_WEBHOOK_SECRET=whsec_… node receiver.mjsimport { createHmac, timingSafeEqual } from "node:crypto"import { createServer } from "node:http"
const SECRET = process.env.SIMLINE_WEBHOOK_SECRET // whsec_…, shown once when you create the endpointconst seen = new Set() // use your database in production
export function verifySimline(secret, header, rawBody, toleranceSeconds = 300) { const parts = header.split(",").map((p) => p.trim().split("=")) const t = Number(parts.find(([k]) => k === "t")?.[1]) if (!Number.isInteger(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex") return parts .filter(([k]) => k === "v1") .some(([, v]) => v.length === expected.length && timingSafeEqual(Buffer.from(v), Buffer.from(expected)))}
createServer((req, res) => { const chunks = [] req.on("data", (c) => chunks.push(c)) req.on("end", () => { const raw = Buffer.concat(chunks).toString("utf8") if (!verifySimline(SECRET, req.headers["simline-signature"] ?? "", raw)) { res.writeHead(401).end() return } const event = JSON.parse(raw) res.writeHead(204).end() // answer fast; do the work after
if (seen.has(event.id)) return // a retry or replay of an event you already handled seen.add(event.id) if (event.type === "message.received") { console.log(`${event.data.contact} wrote: ${event.data.body}`) } else { console.log(event.type, event.id) } })}).listen(Number(process.env.PORT ?? 8788))With Express, use express.raw({ type: "application/json" }) on the route and pass req.body.toString("utf8") to verifySimline.
# receiver.py — pip install flask; SIMLINE_WEBHOOK_SECRET=whsec_… flask --app receiver runimport hashlibimport hmacimport jsonimport osimport time
from flask import Flask, request
app = Flask(__name__)SECRET = os.environ["SIMLINE_WEBHOOK_SECRET"] # whsec_…seen: set[str] = set() # use your database in production
def verify_simline(secret: str, header: str, raw_body: bytes, tolerance_seconds: int = 300) -> bool: parts = [p.strip().split("=", 1) for p in header.split(",") if "=" in p] t = next((v for k, v in parts if k == "t"), "") if not t.isdigit() or abs(time.time() - int(t)) > tolerance_seconds: return False expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest() return any(hmac.compare_digest(v, expected) for k, v in parts if k == "v1")
@app.post("/hook")def hook(): raw = request.get_data() # the exact bytes, before any JSON parsing if not verify_simline(SECRET, request.headers.get("Simline-Signature", ""), raw): return "", 401 event = json.loads(raw) if event["id"] in seen: return "", 204 # already handled: a retry or a replay seen.add(event["id"]) if event["type"] == "message.received": print(f"{event['data']['contact']} wrote: {event['data']['body']}", flush=True) else: print(event["type"], event["id"], flush=True) return "", 204<?php// receiver.php — PHP 8+. Try it with: SIMLINE_WEBHOOK_SECRET=whsec_… php -S localhost:8788 receiver.php
function verify_simline(string $secret, string $header, string $rawBody, int $toleranceSeconds = 300): bool{ $t = ''; $signatures = []; foreach (explode(',', $header) as $part) { [$key, $value] = array_pad(explode('=', trim($part), 2), 2, ''); if ($key === 't') $t = $value; if ($key === 'v1') $signatures[] = $value; } if (!ctype_digit($t) || abs(time() - (int) $t) > $toleranceSeconds) return false; $expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret); foreach ($signatures as $signature) { if (hash_equals($expected, $signature)) return true; } return false;}
$raw = file_get_contents('php://input'); // the exact bytes, before any JSON parsing$secret = getenv('SIMLINE_WEBHOOK_SECRET'); // whsec_…if (!verify_simline($secret, $_SERVER['HTTP_SIMLINE_SIGNATURE'] ?? '', $raw)) { http_response_code(401); exit;}$event = json_decode($raw, true);http_response_code(204);
// Dedupe on $event['id'] (a unique column in your database), then do the work.if ($event['type'] === 'message.received') { error_log($event['data']['contact'] . ' wrote: ' . $event['data']['body']);} else { error_log($event['type'] . ' ' . $event['id']);}In Laravel, read the body with $request->getContent() and the header with $request->header('Simline-Signature').
In our test all three printed +33600000042 wrote: Bonjour, est-ce que la tarte aux pommes est prête ? (accents intact), then message.sent and message.delivered for an outbound text, and answered 401 to a request signed with a made-up v1=.
Retries and delivery
Section titled “Retries and delivery”- Success is any
2xxwithin 10 seconds. Redirects aren’t followed. - Retries: attempt 1 right away, then after 30 seconds, 2 minutes, 10 minutes, 1 hour, 3 hours, 6 hours and 12 hours: 8 attempts over about 22 hours.
- Dead letters: after the 8th failure the delivery is
failed. Replay it from the endpoint’s delivery log in the dashboard or withPOST /v1/webhook-deliveries/{id}/replay. - Auto-disable: an endpoint whose attempts have failed continuously for 3 days is turned off (
disabledReason: "failing"), its pending deliveries are marked failed, and the workspace owners get an email. Re-enable it in the dashboard or withPATCH /v1/webhooks/{id}and{"enabled": true}. - Never lost: the event is recorded in the same database transaction as the status change or the incoming text, so a crash in between can’t drop it.
Each attempt’s status code, timing, error and the first 500 characters of your response are in the Delivery log (and GET /v1/webhooks/{id}/attempts). Attempt errors are explained in Errors.
Duplicates and order
Section titled “Duplicates and order”Delivery is at least once: a retry after a timeout, a replay or a rare race can deliver the same event again, always with the same id.
- Dedupe on the event id (
Simline-Event-Id, oridin the body), with a unique constraint in your database. In our test, a replayedmessage.receivedreached all three receivers, which answered204and did nothing. - Answer first, work after. Slow handlers cause timeouts, and timeouts cause duplicates.
- Don’t rely on order.
message.deliveredcan in principle arrive beforemessage.sent. Move your own status forward only (never replacedeliveredwithsent), or fetchGET /v1/messages/{id}and store what it says.
Replay
Section titled “Replay”A replay sends the same event again (same evt_ id, identical body) as a new delivery, for example after you’ve fixed a bug in your handler:
curl -X POST https://api.simline.dev/v1/webhook-deliveries/whd_AuER0XoaWoMaTw3bPa7KoQ/replay \ -H "Authorization: Bearer $SIMLINE_API_KEY"# 202 {"id": "whd_…", "eventId": "evt_…", "replayOf": "whd_AuER0XoaWoMaTw3bPa7KoQ", "status": "pending", …}Rotate the secret
Section titled “Rotate the secret”curl -X POST https://api.simline.dev/v1/webhooks/whe_Vb3nq0x5cE1h2kF8sYp4Tg/rotate-secret \ -H "Authorization: Bearer $SIMLINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{"graceSeconds": 86400}'You get the new secret. For graceSeconds (default a day, 0 to stop at once, at most 7 days) Simline signs with both, so Simline-Signature carries two v1= values. Deploy the new secret within the grace period; the verifiers above already accept either.
Test events and local development
Section titled “Test events and local development”Send test event in the dashboard (or POST /v1/webhooks/{id}/test) sends a webhook.test event right away, once, ignoring the endpoint’s filters, and returns the attempt’s result.
The live service only calls public https:// URLs. To try your handler on your laptop, expose it with a tunnel, or deploy it and use test events. Simline never sends texts from before the phone was paired.