Signature Verification
Each webhook request includes these headers:| Header | Description |
|---|---|
X-ZendFi-Signature | HMAC-SHA256 signature of the request body |
X-ZendFi-Event | Event type (e.g., payment.confirmed) |
How Signatures Work
The SDK handlers do all of this automatically. If you need to verify manually, here is the algorithm:Manual Verification
- Node.js
- Python
Using the SDK
The SDK handles verification automatically in the webhook handlers:Replay Prevention
An attacker could intercept a valid webhook and re-send it to your endpoint. Protect against this with two mechanisms:1. Timestamp Validation
Check that the webhook timestamp is within an acceptable window (typically 5 minutes):2. Idempotency / Deduplication
Track which events you have already processed and skip duplicates:Webhook Secret Management
Your webhook secret (whsec_...) is used to verify signatures. Protect it with the same care as your API key:
- Store it in environment variables, not in code
- Do not commit it to version control
- Rotate it if you suspect it has been compromised
- Generate a new secret in the ZendFi Dashboard
- Update your application’s
ZENDFI_WEBHOOK_SECRETenvironment variable - Deploy the update
- ZendFi starts signing with the new secret immediately
Error Handling in Webhooks
Your webhook endpoint should always return a200 status code to acknowledge receipt, even if processing fails. This prevents ZendFi from retrying the delivery unnecessarily.
| Attempt | Delay |
|---|---|
| 1 | Immediate |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
| 6 | 12 hours |
| 7+ | Dead letter queue |
HTTPS Requirement
Verification Checklist
Before going to production, verify:- Webhook secret is stored in environment variables
- Signature verification is enabled (automatic with SDK handlers)
- Timestamp tolerance is set (SDK default: 5 minutes)
- Event deduplication is implemented
- Endpoint returns
200for all received webhooks - Endpoint uses HTTPS
- Error handling does not leak sensitive information in responses
- Webhook events are logged for debugging and audit