opyebWebhookLab

Guides · Platform

Verify Shopify webhooks: base64 HMAC

2026-11-29 · 5 min read

One-line answer

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.

ItemValue
HeaderX-Shopify-Hmac-Sha256
Signed contentraw body
AlgorithmHMAC-SHA256
Encodingbase64 (44 chars, ends with =)

Verification code

Node.js
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

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 verifier

Frequently 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