Webhooks Overview
Webhooks let AfriRoute push real-time event notifications to your server as HTTP POST requests, so you don't have to poll the API. When an SMS is delivered, a payment completes, or an identity verification finishes, AfriRoute sends a signed JSON payload to the URL you configure.
🔄 How It Works
- You register an HTTPS endpoint and subscribe to events in the dashboard or via the API.
- An event occurs on the AfriRoute platform.
- AfriRoute sends a
POSTto your endpoint with a JSON body and anX-AfriRoute-Signatureheader. - Your server verifies the signature, processes the event, and responds with
2xx. - If your server does not respond with
2xx, AfriRoute retries with backoff.
📦 Payload Envelope
Every webhook shares the same envelope:
{
"id": "evt_9f8a7b6c",
"event": "sms.delivered",
"created_at": "2026-05-10T10:30:05Z",
"data": {
"message_id": "msg_abc123",
"to": "+251911234567",
"status": "delivered",
"delivered_at": "2026-05-10T10:30:05Z"
}
}
| Field | Type | Description |
|---|---|---|
id | string | Unique event ID — use it for idempotency |
event | string | Event type (e.g. payment.completed) |
created_at | string | ISO 8601 timestamp of the event |
data | object | Event-specific payload |
🧰 Quick Start (Node.js)
webhook.js
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook', (req, res) => {
const { event, data } = req.body;
// Verify the signature first — see the Security page.
console.log(`Received ${event}`);
res.sendStatus(200);
});
app.listen(3000);
🗂️ Event Categories
| Category | Example Events |
|---|---|
| SMS | sms.delivered, sms.failed |
| Payments | payment.completed, payment.failed, payout.completed |
| Voice | voice.completed, voice.failed |
| Identity | verification.completed, verification.failed |
See the full list on the events reference.
💡 Best Practices
- Always verify the signature before trusting a payload — see Webhook Security.
- Respond fast (under 5s) and process heavy work asynchronously.
- Be idempotent — key off the event
id; the same event may arrive more than once. - Return
2xxonly on success so failures are retried. - Use HTTPS — plaintext endpoints are rejected.
📚 Related Resources
Last Updated: May 2026 | Need help? [email protected]