Webhooks
Wazera can send real-time notifications to your application when events occur.
Setting Up Webhooks
Via Dashboard
- Go to Webhooks in your dashboard
- Click Add Webhook
- Enter your endpoint URL
- Select the events you want to receive
- Save and copy the signing secret
Via API
POST /api/v1/webhooks
Content-Type: application/json
X-API-Key: wz_live_your_key_here
{
"url": "https://yourapp.com/webhooks/wazera",
"events": ["message.sent", "message.delivered", "message.read"],
"secret": "your_webhook_secret"
}
Events
| Event | Description |
|---|---|
message.sent |
Message was sent |
message.delivered |
Message was delivered to the recipient |
message.read |
Message was read by the recipient |
message.failed |
Message delivery failed |
message.received |
New incoming message |
contact.created |
New contact was created |
contact.updated |
Contact was updated |
campaign.completed |
Campaign finished sending |
Payload Format
{
"event": "message.delivered",
"timestamp": "2024-01-15T10:30:00Z",
"data": {
"message_id": "msg_abc123",
"to": "201234567890",
"status": "delivered",
"delivered_at": "2024-01-15T10:30:00Z"
}
}
Signature Verification
Every webhook request includes an X-Wazera-Signature header. Verify it to ensure the request is from Wazera:
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_WAZERA_SIGNATURE'];
$secret = config('wazera.webhook_secret');
$expected = hash_hmac('sha256', $payload, $secret);
if (!hash_equals($expected, $signature)) {
abort(401, 'Invalid webhook signature');
}
With Laravel Package
// routes/web.php
Route::post('/webhooks/wazera', function (Request $request) {
Wazera::verifyWebhookSignature($request);
$event = $request->input('event');
$data = $request->input('data');
match ($event) {
'message.delivered' => handleDelivered($data),
'message.read' => handleRead($data),
'message.received' => handleIncoming($data),
default => null,
};
return response()->json(['ok' => true]);
});
Retry Policy
Failed webhook deliveries are retried up to 5 times with exponential backoff:
| Attempt | Delay |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 24 hours |
After 5 failed attempts, the webhook endpoint is disabled and you'll receive an email notification.