InyokeDocs

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 standardwebhooks
import { 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:

  1. Take the part of the secret after whsec_ and base64-decode it. That is the key.
  2. Build the signed content: <webhook-id>.<webhook-timestamp>.<raw body>.
  3. Compute an HMAC-SHA256 of it with the key, and base64-encode the result.
  4. The webhook-signature header holds one or more space-separated v1,<signature> values. Compare yours with each one in constant time. One match means the request is genuine.
  5. Reject a request whose webhook-timestamp is 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.

On this page