Verify Shopify webhooks: base64 HMAC
Shopify base64-encodes the HMAC-SHA256 digest of the raw body and sends it as X-Shopify-Hmac-Sha256.
What is different
The algorithm is HMAC-SHA256 like the others, but the digest is rendered as base64. Compared as hex, the length alone guarantees a mismatch.
| Item | Value |
|---|---|
| Header | X-Shopify-Hmac-Sha256 |
| Signed content | raw body |
| Algorithm | HMAC-SHA256 |
| Encoding | base64 (44 chars, ends with =) |
Verification code
const crypto = require("crypto");
const digest = crypto
.createHmac("sha256", process.env.SHOPIFY_WEBHOOK_SECRET)
.update(rawBody) // Buffer, not parsed JSON
.digest(); // Buffer
const given = Buffer.from(req.get("X-Shopify-Hmac-Sha256") || "", "base64");
const ok = given.length === digest.length &&
crypto.timingSafeEqual(given, digest);
if (!ok) return res.status(401).send("invalid");Decode the base64 and compare bytes rather than comparing the strings, which is fragile around padding and whitespace.
App secret vs store secret
Webhooks delivered to a Shopify app are signed with the app's client secret, while webhooks created in the Admin are signed with that webhook's signing secret. Using the wrong one produces a permanent 401.
Common mistakes
- Comparing hex instead of base64.
- Leaving a line break inside the base64 value.
- Re-serializing the parsed order before verifying.
- Running several stores with one shared secret.
With multiple stores, identify the store from X-Shopify-Shop-Domain first and verify with that store's secret. Trying secrets at random creates cross-tenant risk.
Compare the base64 value byte for byte with the verifier.
Open the signature verifierFrequently asked questions
Does Shopify retry deliveries?
Yes, on no response or 5xx. Deduplicate with X-Shopify-Event-Id and make processing idempotent.
What should I check after the HMAC?
Use X-Shopify-Topic to decide whether to process the event, and re-read the order amount and status through the Admin API.
Are GDPR webhooks signed the same way?
Yes. Compliance webhooks such as customer data requests carry the same header and must be verified identically.
This guide follows the signing schemes published by GitHub, Stripe, Slack, Shopify and Toss Payments.
← Guides