Check that a webhook really came from us
Every delivery is signed with your endpoint's secret. Here's how to check it.
Every webhook delivery carries two headers:
x-cannon-timestamp: when it was sent, in seconds.x-cannon-signature: an HMAC-SHA256 signature, in hex.
The signature is made from the timestamp, a full stop, and the request body, using your endpoint's signing secret (shown once when you added the endpoint).
To check one
- Read the raw request body exactly as it arrived, before any parsing.
- Join the timestamp header, a full stop, and the body:
timestamp.body. - Compute the HMAC-SHA256 of that text with your signing secret, as hex.
- Compare it to
x-cannon-signatureusing a constant-time comparison. If they differ, reject the request.
It's also wise to reject deliveries whose timestamp is more than a few minutes old.
Keep the signing secret on your server only. If you lost it, delete the endpoint and add it again to get a new one.
Was this helpful?
