Examples
Express webhook handler
Express middleware for verified webhook delivery
Example Express middleware that verifies Wocha webhook signatures and dispatches by event type.
Setup
Add your signing secret to .env:
Middleware
Error handling pattern
For production handlers, separate signature errors from business logic errors:
Important notes
- Raw body required — use
express.raw({ type: "application/json" })on the webhook route only. - Route order matters — register the webhook route before
express.json(). - Return 2xx quickly — offload heavy processing to a queue.
- Idempotency — deduplicate by
event_idbefore side effects.