Webhooks
Receive real-time notifications when events happen in your HanDl account. Webhooks let you build reactive integrations without polling the API.
How Webhooks Work
When an event occurs (e.g., a new order is created), HanDl sends an HTTP POST request to your configured endpoint with the event payload. Your server should respond with a 200 status within 10 seconds.
Configuring Webhooks
Set up webhooks from Settings → API or via the API.
| Parameter | Type | Description |
|---|---|---|
| url Required | string | The HTTPS URL to receive webhook events. |
| events Required | array | List of event types to subscribe to. Use '*' for all events. |
| description Optional | string | A label for this webhook endpoint. |
curl -X POST https://api.handl-ng.com/v1/webhooks \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-server.com/webhooks/handl",
"events": ["order.created", "order.updated", "payment.completed"],
"description": "Production webhook"
}'Event Types
Event Payload
Every webhook delivery has the same envelope structure:
{
"id": "evt_abc123",
"object": "event",
"type": "order.created",
"created_at": "2025-06-15T14:30:00Z",
"data": {
"id": "ord_1042",
"object": "order",
"status": "pending",
"customer": {
"name": "Amara Obi",
"phone": "+2348012345678"
},
"total": 850000,
"currency": "NGN"
}
}Verifying Signatures
Every webhook request includes a X-HanDl-Signature header containing an HMAC-SHA256 signature. Verify it to ensure the request came from HanDl.
import crypto from 'crypto';
function verifyWebhook(body, signature, secret) {
const expected = crypto
.createHmac('sha256', secret)
.update(body, 'utf8')
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
// In your webhook handler:
app.post('/webhooks/handl', (req, res) => {
const sig = req.headers['x-handl-signature'];
const valid = verifyWebhook(req.rawBody, sig, 'whsec_...');
if (!valid) return res.status(401).send('Invalid signature');
const event = JSON.parse(req.body);
console.log(event.type); // "order.created"
res.status(200).send('OK');
});Retry Policy
If your endpoint returns a non-2xx status or times out, HanDl retries with exponential backoff:
After 5 failed attempts, the endpoint is marked as unhealthy. You'll receive an email notification. Re-enable from Settings → API.