Delivery modes
There are two ways to receive events:- Webhooks (Push)
- SSE (Pull)
WSAPI sends an HTTP
POST request to a public endpoint you configure. Best for server-based applications that already expose HTTP endpoints.- Configure your instance with Webhook delivery mode and specify a Webhook URL
- When an event occurs, WSAPI sends a
POSTrequest with the event payload - Your server processes the event and responds with a
200status code
Event payload
All events follow this structure regardless of delivery mode:Event types
Four events are system events:
logged_in, logged_out, login_error, and initial_sync_finished. System events are always delivered regardless of event filter configuration and cannot be opted out of.Webhook delivery headers
Every webhookPOST request includes the following HTTP headers:
Verifying event signatures
When a Signing Secret is configured for your instance, WSAPI signs every event payload using HMAC-SHA256. The signature is included in theX-Webhook-Signature header with the format:
- Compute the HMAC-SHA256 of the raw request body using your signing secret as the key
- Hex-encode the result and prepend
sha256= - Compare the computed value with the
X-Webhook-Signatureheader using a constant-time comparison to prevent timing attacks
Delivery and retries
- WSAPI expects a
2xxresponse for webhook deliveries - If no valid response is received, WSAPI retries delivery up to 2 times
- After that, the event is discarded
- Implement idempotent processing to handle potential duplicate deliveries
Best practices
- Respond quickly — return
200immediately and process events asynchronously - Verify signatures — always validate the
X-Webhook-Signatureon incoming events - Handle duplicates — design your handler to be idempotent in case of retries
- Filter events — use event filtering to only receive events you need
- Use HTTPS — always use an HTTPS endpoint for your webhook URL
- Log events — log incoming events for debugging and audit purposes