Synap webhooks deliver real-time notifications to your application when events occur. Use webhooks to trigger workflows, update dashboards, or synchronize state without polling the API.
Every webhook request includes an X-Synap-Signature header containing an HMAC-SHA256 signature of the request body. Always verify this signature to ensure the request is authentic.The signature is computed as:
import hmacimport hashlibdef verify_webhook(request_body: bytes, signature: str, signing_secret: str) -> bool: expected = hmac.new( signing_secret.encode("utf-8"), request_body, hashlib.sha256, ).hexdigest() return hmac.compare_digest(f"sha256={expected}", signature)# In your webhook handler:# body = await request.body()# signature = request.headers["X-Synap-Signature"]# if not verify_webhook(body, signature, SIGNING_SECRET):# return Response(status_code=401)
Always use constant-time comparison (e.g., hmac.compare_digest in Python, crypto.timingSafeEqual in Node.js) to prevent timing attacks when verifying signatures.
If your endpoint returns a non-2xx status code or does not respond within 30 seconds, Synap retries delivery with exponential backoff:
Attempt
Delay
1st retry
1 minute
2nd retry
5 minutes
3rd retry
30 minutes
4th retry
2 hours
5th retry
12 hours
After 5 failed attempts, the event is marked as failed and no further retries are attempted. Failed events are visible in the Dashboard webhook logs for 30 days.
Webhook events are delivered in approximate chronological order but not guaranteed to be strictly ordered. Use the timestamp field in the payload to determine the actual event sequence.
Each event has a unique event_id. Your handler should be idempotent — the same event may be delivered more than once in rare cases (e.g., network timeouts where the response was lost).
Use the Dashboard webhook testing tool to send test events to your endpoint. Navigate to Settings > Webhooks > Test and select an event type.
Use the Synap CLI to trigger test webhook events:
synap webhooks test \ --endpoint-id whep_abc123 \ --event-type conversation.started
For local development, use a tool like ngrok to expose your local server:
# Terminal 1: Start your webhook handlerpython webhook_handler.py # listening on port 8000# Terminal 2: Expose it publiclyngrok http 8000# Use the ngrok HTTPS URL as your webhook endpoint