Signature verification
Verify every webhook before processing it.
Headers
| Header | Description |
|---|---|
X-Webhook-Id | Unique event ID. Use it to avoid processing an event twice. |
X-Webhook-Timestamp | Unix timestamp in seconds when the webhook was created. |
X-Webhook-Signature-Version | Signature algorithm version. Currently v1. |
X-Webhook-Signature | HMAC-SHA256 signature in the v1=<signature> format. |
Verification steps
- Read the raw request body.
- Read
X-Webhook-Timestamp,X-Webhook-Signature-VersionandX-Webhook-Signature. - Check that the signature version is
v1. - Make sure the timestamp is within 5 minutes of the current time in either direction.
- Build the string
timestamp.raw_body. - Compute HMAC-SHA256 with the webhook secret.
- Compare the result with
X-Webhook-Signatureusing a constant-time comparison. - Process the JSON and store
X-Webhook-Id. If the ID was already processed, do not run the business logic again.
If the signature does not match
Reject a webhook with an invalid signature. Example log entry: