Cluster 14 · E-Commerce Provider · Base64 + 5s SLA

Shopify Base64 HMAC Verification, 5-Second Timeout Queueing & 429 Backoff Pattern

Verify Shopify's Base64 `X-Shopify-Hmac-Sha256` header without hex conversion bugs, meet Shopify's strict 5-second HTTP timeout SLA, and survive 19-attempt / 48-hour retries.

100% Browser-Side · WebCrypto crypto.subtle · Strict CSP

2. RFC RateLimit-* & Retry-After Header Builder

IETF RateLimit + RFC 9110
Cloudflare Workers / Edge Middleware Helper (ratelimit.ts)
// Cloudflare Workers RFC RateLimit-* + Retry-After Response Helper
export function rateLimitResponse(remaining: number, resetSec: number, throttled: boolean): Response {
  const headers: Record<string, string> = {
    "Content-Type": "application/json",
    "RateLimit-Policy": '"webhook-ingest";q=40;w=1',
    "RateLimit": `"webhook-ingest";r=${Math.max(0, remaining)};t=${Math.max(0, resetSec)}`,
    "X-RateLimit-Limit": "40",
    "X-RateLimit-Remaining": String(Math.max(0, remaining)),
    "X-RateLimit-Reset": String(Math.floor(Date.now() / 1000) + Math.max(0, resetSec)),
  };
  if (throttled) {
    headers["Retry-After"] = String(Math.max(1, resetSec));
    headers["Cache-Control"] = "no-store";
    return new Response(JSON.stringify({ error: "rate_limited", retryAfterSec: resetSec }), { status: 429, headers });
  }
  return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
}
RateLimit-* & Retry-After Compliance Score
90 / 100
PASS
RL-001: RFC 9110 §10.2.3 Retry-After present on HTTP 429 PASS
Communicates deterministic cooldown window so upstream webhook dispatchers pause safely.
RL-002: Quota math consistent (0/40 remaining over 1s window) PASS
Policy "webhook-ingest" matches IETF draft-ietf-httpapi-ratelimit-headers structured field syntax.
RL-004: Reset / Retry-After (4s) exceeds policy window (1s) WARN
Clients may infer penalty boxing when t > w; document penalty windows or align t <= w.
Generated HTTP Response Headers
HTTP/1.1 429 Too Many Requests
RateLimit-Policy: "webhook-ingest";q=40;w=1
RateLimit: "webhook-ingest";r=0;t=4
Retry-After: 4
X-RateLimit-Limit: 40
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1796137204
Cache-Control: no-store
WebhookSLA Guard · Live Check $29 WebhookSLA Guard Kit

Verify Live Webhook Replay Defense, 429 Retry-After & DLQ SLA Readiness

Run a live webhook endpoint & SLA audit on WebhookSLA Guard (webhook.runglab.dev), grab the turnkey $29 WebhookSLA Guard Kit (WebCrypto HMAC verifiers, replay-window store, RFC RateLimit-* middleware & DLQ runbooks) on Creem, or audit webhook OpenAPI specs on SpecDiff (spec.runglab.dev). Need a PayPal invoice? Email [email protected].

Webhook SLA, Signature & Retry Specification Matrix

Control / Header Production Baseline Reliability & Security Rationale
Signature Encoding Base64 (NOT Hex) `X-Shopify-Hmac-Sha256` encodes the 32-byte HMAC-SHA256 digest as Base64
Delivery SLA Timeout 5.0 seconds strict Shopify aborts connections slower than 5s and increments consecutive failure counts
Retry Policy 19 retries over 48 hours Auto-deletes webhook subscriptions after repeated multi-day failures
Deduplication Header X-Shopify-Webhook-Id Use `X-Shopify-Webhook-Id` + `X-Shopify-Topic` for idempotent order processing

Shopify Base64 HMAC Verifier (WebCrypto + Timing-Safe)

shopify-webhook-verify.ts
export async function verifyShopifyWebhook(rawBody: string, hmacHeader: string, clientSecret: string): Promise<boolean> {
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey("raw", enc.encode(clientSecret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
  const digest = new Uint8Array(await crypto.subtle.sign("HMAC", key, enc.encode(rawBody)));
  const expectedBase64 = btoa(String.fromCharCode(...digest));
  const a = enc.encode(hmacHeader.trim());
  const b = enc.encode(expectedBase64);
  if (a.length !== b.length) return false;
  let diff = 0;
  for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
  return diff === 0;
}

Shopify Flash-Sale 429 Retry-After Shedding Headers

shopify-429-headers.http
HTTP/1.1 429 Too Many Requests
RateLimit-Policy: "shopify-ingest";q=40;w=1
RateLimit: "shopify-ingest";r=0;t=4
Retry-After: 4
Cache-Control: no-store

Implementation Steps & Key Insights

  1. Compute HMAC-SHA256 over the exact raw request body using your Shopify App Client Secret and encode the 32-byte digest as Base64.
  2. Compare against `X-Shopify-Hmac-Sha256` in constant time and return `401` on invalid signatures.
  3. Enqueue order/inventory events immediately using `X-Shopify-Webhook-Id` as your queue deduplication ID.
  4. Always return `200 OK` within 5 seconds so Shopify never disables your app's webhook subscription.
  • The #1 Shopify webhook bug is comparing a lowercase hex HMAC digest against Shopify's Base64 `X-Shopify-Hmac-Sha256` header.
  • Shopify disables webhook subscriptions automatically after 19 consecutive failures over 48 hours — making fast queue ingestion + DLQ monitoring critical.
  • During BFCM flash sales, shedding excess traffic with `429` + `Retry-After` keeps downstream databases alive while letting Shopify retry cleanly.

Common Production Pitfalls

  • Encoding Shopify HMAC output as `.digest('hex')` instead of `.digest('base64')`.
  • Executing Shopify GraphQL Admin API back-calls synchronously before answering the webhook POST.
  • Ignoring `X-Shopify-Webhook-Id` deduplication during burst order updates.
Ship Faster: Audit your live endpoint on webhook.runglab.dev or grab the $29 WebhookSLA Guard Kit.

More Enterprise Webhook SLA & Signature Guides

← Back to Webhook SLA Kit Hub · WebhookSLA Guard ($29 Kit) → · SpecDiff OpenAPI Audit → · Cluster 7B: CORS & HMAC → · Cluster 9: OpenAPI OWASP →

Frequently Asked Questions

Why does Shopify fail valid-looking HMAC signatures when JSON looks identical?

Shopify encodes `X-Shopify-Hmac-Sha256` in Base64 and signs raw UTF-8 bytes (including Unicode escape formatting). Always read raw body bytes.

What happens if my endpoint takes 6 seconds to respond to Shopify?

Shopify closes the request at 5 seconds, counts it as a failed delivery, and schedules retries over up to 48 hours (19 attempts).

Can I model Shopify's 48-hour retry curve in this tool?

Yes — switch to the 'Exponential Backoff & DLQ' tab or click the Shopify preset to simulate attempt spacing and DLQ depth.