Webhooks
The SMS webhook API: receive events in your own system as codes are sent, delivered, failed and verified, and check every delivery's signature before trusting it. It doubles as an SMS delivery API for your order and login screens.
Webhooks
Webhook events
Add an HTTPS endpoint under Webhooks in your dashboard and DiOTP will POST a JSON event to it as things happen. Reply with any 2xx; anything else is retried with increasing delays.
| Event | Sent when |
|---|---|
otp.sent | A code was handed to the network. |
otp.delivered | The network confirmed delivery to the handset, where delivery reports are available. |
otp.failed | The network reported the message could not be delivered. |
otp.verified | The user’s code was verified. |
| Header | Contains |
|---|---|
X-Diorbit-Event | The event name. |
X-Diorbit-Timestamp | Unix time the delivery was signed. |
X-Diorbit-Signature | Hex HMAC-SHA256 of timestamp.body with your webhook secret. |
POST /your/webhook HTTP/1.1 Content-Type: application/json X-Diorbit-Event: otp.sent X-Diorbit-Timestamp: 1794850000 X-Diorbit-Signature: 9f2c4b1e0a7d... { "event": "otp.sent", "created_at": "2026-11-16T10:00:00+00:00", "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "channel": "sms" }
Webhooks
Verifying signatures
Check every delivery before trusting it. Recompute the signature from the raw body and the timestamp header with your webhook secret (shown once when you added the endpoint), compare it in constant time, and reject timestamps more than five minutes old to stop replays.
# Each delivery carries three headers: # X-Diorbit-Event: otp.verified # X-Diorbit-Timestamp: 1794850000 # X-Diorbit-Signature: <hex HMAC-SHA256 of "<timestamp>.<raw body>"> # # Recompute it with your webhook secret and compare: printf '%s.%s' "$TIMESTAMP" "$RAW_BODY" \ | openssl dgst -sha256 -hmac "$DIOTP_WEBHOOK_SECRET" -hex
import crypto from "node:crypto"; // Use the raw request body, exactly as received, not re-serialised JSON. export function isFromDiOTP(rawBody, headers, secret) { const timestamp = headers["x-diorbit-timestamp"]; const signature = headers["x-diorbit-signature"]; const expected = crypto .createHmac("sha256", secret) .update(`${timestamp}.${rawBody}`) .digest("hex"); const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300; return fresh && crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature)); }
import hashlib, hmac, time def is_from_diotp(raw_body: bytes, headers, secret: str) -> bool: timestamp = headers["X-Diorbit-Timestamp"] signature = headers["X-Diorbit-Signature"] expected = hmac.new( secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256 ).hexdigest() fresh = abs(time.time() - int(timestamp)) < 300 return fresh and hmac.compare_digest(expected, signature)
<?php function isFromDiOTP(string $rawBody, array $headers, string $secret): bool { $timestamp = $headers["X-Diorbit-Timestamp"]; $signature = $headers["X-Diorbit-Signature"]; $expected = hash_hmac("sha256", $timestamp . "." . $rawBody, $secret); $fresh = abs(time() - (int) $timestamp) < 300; return $fresh && hash_equals($expected, $signature); }
Setting up an endpoint
Add an HTTPS URL under Webhooks in your dashboard. It receives every event: sent, delivered, failed and verified. DiOTP shows a signing secret once, starting with whsec_. Store it with your other server secrets: it is how you prove each delivery came from us.
Your endpoint should check the signature, record the event and reply with any 2xx status within 10 seconds. Do slow work, such as sending emails, after you reply. Anything other than a 2xx, or no reply in time, counts as a failure and is retried.
Event examples
Every event carries its name, the time it was created and the request_id from the send, so you can match it to the code your system asked for.
{
"event": "otp.sent",
"created_at": "2026-11-16T10:00:00+00:00",
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"channel": "sms"
}{
"event": "otp.delivered",
"created_at": "2026-11-16T10:00:04+00:00",
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"channel": "sms",
"status": "delivered"
}{
"event": "otp.verified",
"created_at": "2026-11-16T10:01:12+00:00",
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7"
}Retries
A failed delivery is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours: six attempts in all. After the last one the delivery is kept, not lost, and our support team can send it again. The same event can arrive more than once, so make your handler idempotent: if you have already recorded an event for that request_id and event name, reply 200 and do nothing.
Delivery outcomes
| Your reply | Result | What happens |
|---|---|---|
| 2xx | Delivered | Any 2xx reply marks the delivery done. The body is ignored. |
| 3xx, 4xx, 5xx | Retried | Redirects are not followed. Any non-2xx reply is retried on the schedule above. |
| Timeout | Retried | No reply within 10 seconds, or the URL could not be reached. |
| Removed | Stopped | If you delete or switch off the endpoint, pending deliveries stop. |
Webhooks: FAQ
Usually, but not always: a retried otp.sent can arrive after otp.verified. Use created_at to order events, and treat otp.verified as final.
Delivery reports depend on the mobile network and are not available on every route. An OTP that the user verified was clearly delivered, whether or not a delivery event arrived.
Send yourself a code in test mode. Each step posts a real, signed event to your endpoint, so you can check your signature code against genuine deliveries before you go live.
Remove the webhook in your dashboard and add the same URL again. You get a new secret and the old one stops working straight away, so update your server with the new secret at the same time.
Need help integrating?
Our team helps with integration, DLT templates and going live.

