Receive SMS delivery reports with webhooks

Set up the SMS webhook, read sms.sent and sms.failed events, and verify the signature in Laravel, Node.js and Python.

Instead of checking each SMS, let Fortwave tell your server when a message is sent or fails. This guide sets up the webhook, explains what Fortwave sends, and verifies each request in Laravel, Node.js and Python.

Set up the webhook

  1. Open Settings from the user menu and, under Developer, select Webhooks. The SMS webhook card holds the settings below.
  2. Enter your Webhook URL. It must be reachable over HTTPS from the internet.
  3. Under Events to receive, choose sms.sent, sms.failed or both, then save.
  4. Copy the Signing secret into your server configuration, for example as FORTWAVE_WEBHOOK_SECRET.
  5. Turn the webhook on with the switch once your endpoint is deployed.
The SMS webhook settings with the webhook URL, the masked signing secret and the SMS Sent and SMS Failed events
Settings → Developer → Webhooks.

What Fortwave sends

Each status change is a POST with a JSON body. X-Webhook-Event names the event and X-Webhook-Signature signs the body.

sms.sent
{
  "event": "sms.sent",
  "timestamp": "2026-11-14T09:30:02+00:00",
  "data": {
    "message_id": "01JCX4Q8V6M2R7T9K3N5P1W0YZ",
    "phone_number": "+25761000000",
    "status": "sms.sent",
    "sent_at": "2026-11-14T09:30:01+00:00",
    "failed_at": null
  }
}
  • data.message_id is the id that POST /v1/sms returned when you sent the message, so you can match each webhook to the message in your database.
  • sms.sent means the operator accepted the message for delivery; sms.failed means it could not be delivered, with failed_at set.
  • Only one webhook URL is set per company, and it receives the events of every sender ID.

Verify the signature

X-Webhook-Signature is the hex HMAC-SHA256 of the raw request body, keyed with your signing secret. Compute it over the exact bytes you received, before parsing the JSON, and compare in constant time. Reject any request whose signature does not match.

Laravel
// routes/api.php: API routes have no CSRF check, which webhooks need.
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::post('/webhooks/fortwave', function (Request $request) {
    $expected = hash_hmac('sha256', $request->getContent(), config('services.fortwave.webhook_secret'));

    if (! hash_equals($expected, (string) $request->header('X-Webhook-Signature'))) {
        abort(401);
    }

    $data = $request->json('data');
    // $data['message_id'] is the id POST /v1/sms returned for this message.
    // Record $request->header('X-Webhook-Event'): sms.sent or sms.failed.

    return response()->noContent();
});
Node.js (Express)
// Express: read the raw body, since the signature covers the exact bytes sent.
import express from 'express'
import { createHmac, timingSafeEqual } from 'node:crypto'

const app = express()

app.post('/webhooks/fortwave', express.raw({ type: 'application/json' }), (req, res) => {
  const expected = createHmac('sha256', process.env.FORTWAVE_WEBHOOK_SECRET).update(req.body).digest('hex')
  const received = req.get('X-Webhook-Signature') ?? ''

  const valid = received.length === expected.length && timingSafeEqual(Buffer.from(received), Buffer.from(expected))
  if (!valid) return res.sendStatus(401)

  const { event, data } = JSON.parse(req.body)
  // data.message_id is the id POST /v1/sms returned; event is sms.sent or sms.failed.

  res.sendStatus(204)
})
Python (Flask)
# Flask: verify against the raw body, before parsing it.
import hashlib
import hmac
import os

from flask import Flask, abort, request

app = Flask(__name__)


@app.post("/webhooks/fortwave")
def fortwave_webhook():
    expected = hmac.new(
        os.environ["FORTWAVE_WEBHOOK_SECRET"].encode(), request.get_data(), hashlib.sha256
    ).hexdigest()
    if not hmac.compare_digest(expected, request.headers.get("X-Webhook-Signature", "")):
        abort(401)

    payload = request.get_json()
    # payload["data"]["message_id"] is the id POST /v1/sms returned;
    # payload["event"] is sms.sent or sms.failed.

    return "", 204

Respond quickly

Answer with any 2xx status within 10 seconds, and do slow work, such as notifying a user, after responding or in a queue. If your server times out or returns an error, Fortwave tries again, up to 5 attempts in total, waiting 10 seconds, 30 seconds, 1 minute and 5 minutes between them. The same event can therefore arrive more than once, so make your handler safe to run twice for the same message_id and event.

Still need help?

Our team answers Monday to Friday, during business hours (CAT).