Contents

Webhooks

Signed status events, retries and verification.

Add an HTTPS endpoint under Developers → Webhooks for a project and choose its events. SMS21 sends a signed POST whenever a message changes status. The signing secret (whsec_…) is shown once.

Events

EventWhen
message.submittedHanded to a provider.
message.sentLeft the provider platform.
message.deliveredDelivered to the handset.
message.failedCould not be delivered.
message.rejectedRefused (invalid number, policy, DLT).
message.expiredNo final report in time.
message.receivedSomeone messaged one of your numbers: an SMS reply, a WhatsApp Official reply or a message to a linked WhatsApp Connect number (see channel, senderName and media).
webhook.testSent when you click “Send test event”.
"sample": trueMarks an example message.received sent from the dashboard (“Send sample message”). It references nothing.
Body
{
  "id": "evt_01k55q8y4m3d9v7x2c6b0n1r8t",
  "event": "message.delivered",
  "timestamp": "2026-09-15T10:30:04.000Z",
  "messageId": "msg_01k55q8y4m3d9v7x2c6b0n1r8t",
  "status": "delivered",
  "channel": "sms",
  "type": "otp",
  "environment": "live",
  "failure": null
}
HeaderValue
sms21-signaturet=<unix seconds>,v1=<hex>
sms21-timestampSame as t.
sms21-event-idThe event id — identical on every retry.
sms21-event-typeThe event name.
sms21-delivery-idThis delivery to this endpoint.
sms21-attemptAttempt number, starting at 1.

Verify every request

  1. Read the raw body — before any JSON parsing or re-serialization.
  2. Compute HMAC-SHA256 of "<t>.<raw body>" with your secret and compare it in constant time with each v1 value (several appear while a secret rotates).
  3. Reject the request when t is more than 5 minutes away from your clock.
  4. Ignore event IDs you have already processed.
import { webhooks, WebhookSignatureError } from '@sms21/node';

// Express: app.post('/webhooks/sms21', express.raw({ type: 'application/json' }), handler)
export function handler(req, res) {
  let event;
  try {
    event = webhooks.constructEvent({
      payload: req.body,                         // Buffer
      signature: req.headers['sms21-signature'],
      secret: process.env.SMS21_WEBHOOK_SECRET,
    });
  } catch (error) {
    if (error instanceof WebhookSignatureError) return res.sendStatus(400);
    throw error;
  }
  res.sendStatus(204);
  queue.add('sms21-event', event, { jobId: event.id });   // dedupe on event.id
}

Responses and retries

  • Answer with any 2xx within 10 seconds. Process the event asynchronously.
  • Other responses, timeouts and connection errors are retried with backoff — 30 s, 2 min, 10 min, 30 min, 1 h, 3 h, 6 h — up to 8 attempts by default.
  • An endpoint that keeps failing (50 consecutive failures by default) is disabled; re-enable it in the dashboard.
  • Deliveries are at-least-once and can arrive out of order: compare timestamp and never move a message backwards.

Endpoint security

Endpoints must be public HTTPS URLs; SMS21 refuses private and internal addresses. Store the secret like a password, and rotate it from the dashboard if it leaks.