My webhook signature doesn't match
developers-signature-mismatchOn this page
If your signature never matches, you're usually hashing parsed JSON instead of the raw body, using the wrong secret, or the old header's formula.
What you see
Your endpoint works out the HMAC for a delivery, and it never equals the value in Skeduler's signature header, so you reject every delivery.
Why it happens
- You're hashing parsed JSON. Your framework parsed the body, and you turned it back into JSON before hashing. The bytes change (spacing, key order, escaping), so the signature does too.
- You're using the wrong secret. Each subscription has its own
signing_secret. It isn't your app's client secret, and it isn't another subscription's secret. - You're mixing up the two headers.
X-Skeduler-Signature-V2signs"<t>.<raw body>". The olderX-Skeduler-Signaturesigns the body alone and starts withsha256=. - Your clock is out. If you reject deliveries whose
tis more than 5 minutes from your clock, as you should, a server clock that's wrong rejects good ones.
How to fix it
-
Hash the raw request body, exactly as received. In Express, use
express.raw({ type: "application/json" })on the webhook route, notexpress.json(). In PHP, readphp://input. -
Use the
signing_secretfrom the answer you got when you created this subscription. If you've lost it:- subscribe again with the same event and URL, and Skeduler answers with the existing subscription and its secret, or
- delete the subscription and subscribe again for a new secret.
The web app doesn't show signing secrets.
-
For
X-Skeduler-Signature-V2(t=<unix seconds>,v1=<hex>), work outHMAC-SHA256(secret, "<t>.<raw body>")as lowercase hex, and compare it tov1. If you check the older header, compare against the hex aftersha256=. Use a constant-time comparison either way. -
Keep your server's clock in sync, for example with NTP.
The full steps, with Node and PHP code, are in Verify a webhook signature.
Related
In this section
- How webhooks work: subscriptions, events and deliveries
- Subscribe to webhook events
- Verify a webhook signature
- Webhook events and their payloads
- Webhook recipes: subscribe, verify and handle deliveries
- Webhook retries, duplicates and switch-off
- I'm not receiving webhook deliveries
- My webhook subscription was disabled
- Does an integration get webhooks for its own API writes?