Skip to main content

Webhook Configuration

Register the URLs that AfriRoute should call and choose which events each endpoint receives. You can manage webhooks from the dashboard or programmatically through the API documented below.

๐Ÿš€ Quick Startโ€‹

curl -X POST https://api.afriroute.ai/api/v1/webhooks \
-H "Authorization: Bearer $AFRIROUTE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourapp.com/webhook",
"events": ["sms.delivered", "payment.completed"],
"description": "Production events"
}'

๐Ÿ“ก Endpointsโ€‹

MethodPathDescription
POST/v1/webhooksCreate a webhook
GET/v1/webhooksList all webhooks
GET/v1/webhooks/:idRetrieve a webhook
PATCH/v1/webhooks/:idUpdate URL, events, or status
DELETE/v1/webhooks/:idDelete a webhook
POST/v1/webhooks/:id/testSend a test event

Create Webhook โ€” Parametersโ€‹

FieldTypeRequiredDescription
urlstringYesHTTPS endpoint to receive events
eventsarrayYesEvent types to subscribe to (use ["*"] for all)
descriptionstringNoHuman-readable label
enabledbooleanNoWhether the webhook is active (default true)

๐Ÿ’ป Code Samplesโ€‹

Node.js โ€” create
const res = await fetch('https://api.afriroute.ai/api/v1/webhooks', {
method: 'POST',
headers: { 'Authorization': 'Bearer $AFRIROUTE_API_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({
url: 'https://yourapp.com/webhook',
events: ['sms.delivered', 'sms.failed', 'payment.completed']
})
});
const webhook = await res.json();
console.log(webhook.id, webhook.secret);
Python โ€” list
import requests
res = requests.get(
'https://api.afriroute.ai/api/v1/webhooks',
headers={'Authorization': 'Bearer $AFRIROUTE_API_KEY'}
)
for wh in res.json()['data']:
print(wh['id'], wh['url'], wh['enabled'])

๐Ÿ“Š Responseโ€‹

{
"id": "wh_5k2j9",
"url": "https://yourapp.com/webhook",
"events": ["sms.delivered", "payment.completed"],
"secret": "whsec_4a1b2c3d4e5f6071",
"enabled": true,
"created_at": "2026-05-10T09:00:00Z"
}
Store the secret immediately

The secret is returned only once at creation. Save it securely โ€” you will need it to verify signatures. If lost, rotate it from the dashboard.

๐Ÿงช Testing an Endpointโ€‹

curl -X POST https://api.afriroute.ai/api/v1/webhooks/wh_5k2j9/test \
-H "Authorization: Bearer $AFRIROUTE_API_KEY"

This delivers a sample event so you can confirm your endpoint is reachable and verifies signatures correctly. For local development, expose your server with a tunnel such as ngrok.

๐Ÿ’ก Best Practicesโ€‹

  • Use separate endpoints for production and sandbox environments.
  • Subscribe only to events you handle to reduce noise and load.
  • Disable rather than delete a webhook while debugging to preserve its secret.
  • Rotate the signing secret periodically and on any suspected leak.
  • Monitor delivery health in the dashboard and alert on rising failure rates.

โš ๏ธ Error Handlingโ€‹

CodeHTTPDescription
INVALID_URL400URL is not a valid HTTPS endpoint
INVALID_EVENT400One or more event types are unknown
WEBHOOK_LIMIT_REACHED422Plan webhook limit exceeded
WEBHOOK_NOT_FOUND404No webhook with that ID

See the error code reference for the full list.


Last Updated: May 2026 | Need help? [email protected]