Skip to content

Webhooks ​

A webhook is an address of yours that the server calls when something happens, so your application does not have to keep asking.

Add one ​

In the dashboard, an owner, admin or developer opens Webhooks, enters the address and picks the events. The address must use https and be reachable from the internet.

The signing secret is shown once, when the webhook is created. Store it with your other secrets. You need it to check each request.

Events ​

EventSent when
sms.queuedA message entered the queue
sms.assignedA message was handed to a phone
sms.sentThe mobile network accepted a message
sms.deliveredThe network reported the message delivered
sms.delivery_failedThe network reported it could not be delivered
sms.failedA message was not sent, and will not be tried again by the server
device.onlineA phone came online
device.offlineA phone stopped reporting in
incoming_sms.receivedOne of your SIM cards received a message

Most applications need sms.delivered and sms.failed, and incoming_sms.received if they handle replies.

What you receive ​

A POST with a JSON body:

json
{
  "eventId": "5b0f6a7b-8c90-4e2a-9c31-8f2a1c0e4b7d",
  "event": "sms.delivered",
  "createdAt": "2026-12-01T08:30:14Z",
  "data": {
    "messageId": "8f2a1c0e-4b7d-4e2a-9c31-5d0f6a7b8c90",
    "recipient": "+250788123456",
    "status": "DELIVERED",
    "reference": "ORDER-10001",
    "description": "Delivery confirmed by the mobile network"
  }
}

data depends on the event:

EventsFields in data
sms.*messageId, recipient, status, reference, description
device.*deviceId, deviceName, status
incoming_sms.receivedincomingSmsId, deviceId, sender, message, receivedAt

And these headers:

HeaderValue
X-YourSMS-EventThe event name
X-YourSMS-DeliveryAn identifier of this delivery
X-YourSMS-Signaturet=<unix seconds>,v1=<signature>

Answer quickly ​

Answer with any 2xx status within 10 seconds. Do slow work after answering.

Anything else counts as a failure, and the server tries again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours. After that it gives up on that event. The Deliveries list on the Webhooks page shows recent attempts and their answers.

Expect repeats ​

A retried delivery carries the same eventId as the first attempt. Your answer may have been lost on the way, so the same event can arrive twice. Remember the eventIds you have handled and ignore repeats.

Events can also arrive out of order. Trust the status in the newest event by createdAt, or read the message.

Check the signature ​

Anyone who learns your address can post to it. The signature proves a request came from your server.

  1. Take t and v1 from the X-YourSMS-Signature header.
  2. Compute HMAC-SHA256 of the text <t>.<raw request body> with your signing secret as the key, written as lower-case hexadecimal.
  3. Compare it with v1, using a comparison that takes the same time whatever the input.
  4. Refuse the request if t is more than five minutes old.

Use the body exactly as it arrived. Parsing the JSON and writing it out again changes the bytes, and the signature no longer matches.

js
import crypto from 'node:crypto'
import express from 'express'

const app = express()
const secret = process.env.YOURSMS_WEBHOOK_SECRET

// express.raw keeps the body as the bytes that were signed.
app.post('/hooks/sms', express.raw({ type: 'application/json' }), (req, res) => {
  const header = req.get('X-YourSMS-Signature') ?? ''
  const { t, v1 } = Object.fromEntries(header.split(',').map((part) => part.split('=')))
  const expected = crypto.createHmac('sha256', secret).update(`${t}.${req.body}`).digest('hex')

  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300
  const genuine =
    v1?.length === expected.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected))
  if (!fresh || !genuine) return res.sendStatus(400)

  const event = JSON.parse(req.body)
  // Hand the event to your own code here, then answer.
  res.sendStatus(204)
})
python
import hashlib
import hmac
import os
import time

from flask import Flask, request

app = Flask(__name__)
secret = os.environ["YOURSMS_WEBHOOK_SECRET"].encode()


@app.post("/hooks/sms")
def sms_hook():
    header = request.headers.get("X-YourSMS-Signature", "")
    parts = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
    timestamp, signature = parts.get("t", ""), parts.get("v1", "")

    # request.get_data() is the body as the bytes that were signed.
    signed = timestamp.encode() + b"." + request.get_data()
    expected = hmac.new(secret, signed, hashlib.sha256).hexdigest()

    fresh = timestamp.isdigit() and abs(time.time() - int(timestamp)) < 300
    if not fresh or not hmac.compare_digest(signature, expected):
        return "", 400

    event = request.get_json()
    # Hand the event to your own code here, then answer.
    return "", 204

Turn one off ​

On the Webhooks page, Turn off stops deliveries without losing the webhook, and Delete removes it.