API v1REST · JSON · HTTPS

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.

EventSent when
otp.sentA code was handed to the network.
otp.deliveredThe network confirmed delivery to the handset, where delivery reports are available.
otp.failedThe network reported the message could not be delivered.
otp.verifiedThe user’s code was verified.
HeaderContains
X-Diorbit-EventThe event name.
X-Diorbit-TimestampUnix time the delivery was signed.
X-Diorbit-SignatureHex HMAC-SHA256 of timestamp.body with your webhook secret.
Example delivery
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.

Compute the HMAC over the raw bytes you received. Parsing and re-serialising the JSON changes it.
# 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

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.

otp.sent
{
  "event": "otp.sent",
  "created_at": "2026-11-16T10:00:00+00:00",
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "channel": "sms"
}
otp.delivered
{
  "event": "otp.delivered",
  "created_at": "2026-11-16T10:00:04+00:00",
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "channel": "sms",
  "status": "delivered"
}
otp.verified
{
  "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 replyResultWhat happens
2xxDeliveredAny 2xx reply marks the delivery done. The body is ignored.
3xx, 4xx, 5xxRetriedRedirects are not followed. Any non-2xx reply is retried on the schedule above.
TimeoutRetriedNo reply within 10 seconds, or the URL could not be reached.
RemovedStoppedIf 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.

Need help integrating?

Our team helps with integration, DLT templates and going live.