Webhook Integration
Webhooks push real-time events from Cronozen to your endpoint — decision sealed, payment completed, attendance verified, certificate issued. This guide covers setup, security verification, and retry handling.When to Use Webhooks vs Polling
Use webhooks
Real-time events (decisions, payments, attendance), low-latency UX requirements, or events that don’t have predictable timing.
Use polling
Batch reconciliation, simple dashboards, or environments where receiving inbound requests is impractical.
Setup (3 Steps)
1. Register your endpoint
signingSecret — store this securely. It is shown only once.
2. Verify the signature on every request
Every webhook payload includes anX-Cronozen-Signature header. Verify it with HMAC-SHA256:
3. Respond fast
Return2xx within 5 seconds. If your handler does heavy work, queue it and return immediately:
Retry Behavior
If your endpoint returns non-2xx or times out, Cronozen retries with exponential backoff:| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | 30s |
| 3 | 2 min |
| 4 | 10 min |
| 5 | 1 hour |
| 6 | 6 hours |
| 7 | 24 hours |
failed. You can manually retry from the dashboard or via the API:
Idempotency — Critical
Webhook retries mean the same event can arrive multiple times. Always treat handlers as idempotent. Every event carries a uniqueeventId. Store it on first receipt and reject duplicates:
Event Ordering
Cronozen does not guarantee delivery order. If event A is created before event B, your endpoint may receive B before A. Design handlers to be order-independent, or use the event’screatedAt and your local state to reconcile.
For workflows that strictly depend on order (e.g., “approve then disburse”), use the Workflows API instead — it enforces sequence within a single workflow instance.
Local Development
For local testing, use a tunnel likengrok or cloudflared:
Security Checklist
- Verify signature on every request
- Use
crypto.timingSafeEqual(not string comparison) to prevent timing attacks - Return 2xx within 5 seconds
- Store event IDs for idempotency
- Rotate signing secret periodically (
POST /webhooks/{id}/rotate-secret) - Restrict endpoint to inbound traffic only (no auth-required pages)
- Log signature failures — repeated failures may indicate replay attacks