Verify requests
Check each request's signature with your signing secret before you act on it.
Requests are signed to the Standard Webhooks spec, so its libraries verify them as they are. Verify against the raw request body, before you parse it. A body that has been parsed and serialized again won't match its signature.
npm install standardwebhooksimport { Webhook } from 'standardwebhooks';
const wh = new Webhook(process.env.INYOKE_SIGNING_SECRET); // "whsec_..."
// Throws on a bad signature, or a timestamp over 5 minutes off.
const event = wh.verify(rawBody, headers);Verify by hand
If you'd rather not add a library:
- Take the part of the secret after
whsec_and base64-decode it. That is the key. - Build the signed content:
<webhook-id>.<webhook-timestamp>.<raw body>. - Compute an HMAC-SHA256 of it with the key, and base64-encode the result.
- The
webhook-signatureheader holds one or more space-separatedv1,<signature>values. Compare yours with each one in constant time. One match means the request is genuine. - Reject a request whose
webhook-timestampis more than 5 minutes from your clock.
Rotating the secret
Rotate a secret from the endpoint's ⋯ menu in Integrations. The new secret is shown once.
For 24 hours after a rotation, every request carries two signatures, one for each secret. A receiver holding either secret keeps verifying while you switch it over, so you can rotate without missing an event.