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
- Open Settings from the user menu and, under Developer, select Webhooks. The SMS webhook card holds the settings below.
- Enter your Webhook URL. It must be reachable over HTTPS from the internet.
- Under Events to receive, choose
sms.sent,sms.failedor both, then save. - Copy the Signing secret into your server configuration, for example as
FORTWAVE_WEBHOOK_SECRET. - Turn the webhook on with the switch once your endpoint is deployed.

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.
{
"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_idis theidthatPOST /v1/smsreturned when you sent the message, so you can match each webhook to the message in your database.sms.sentmeans the operator accepted the message for delivery;sms.failedmeans it could not be delivered, withfailed_atset.- 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.
// 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();
});// 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)
})# 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 "", 204Respond 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.
Related
- Send SMS and OTP codes from Laravel, Node.js or Python.
- WhatsApp has its own webhooks with more events, such as delivered, read and received; see the WhatsApp API reference.
Still need help?
Our team answers Monday to Friday, during business hours (CAT).