Skip to content
Create an account

WhatsApp webhooks

WhatsApp webhooks #

Callisto sends a JSON POST to the instance's webhook_url for each event: message.sent, message.failed, message.status, message.received, instance.qr, instance.connected, instance.disconnected.

The body holds event, instance_id, timestamp, occurred_at, instance, data.

Check the X-Callisto-Signature header (sha256= followed by the HMAC-SHA256 of the raw body, keyed with the instance secret) and drop duplicates using X-Callisto-Delivery, which stays the same on every attempt. When the instance has no secret, no signature is sent.

$body = file_get_contents('php://input');
$expected = 'sha256=' . hash_hmac('sha256', $body, $instanceSecret);
$valid = hash_equals($expected, $_SERVER['HTTP_X_CALLISTO_SIGNATURE'] ?? '');

Only a 2xx answer counts as received. Your endpoint has 10 s to answer. A failed delivery (network error, 5xx, 408, 425 or 429) is retried five times, after 1 min, 5 min, 30 min, 2 h and then 6 h, about 8.5 hours in all. Any other answer (3xx, 4xx) stops the attempts: redirects are not followed.