published fresh until

Why does my Stripe webhook fail signature checks or fire twice?

Summary When implementing a Stripe webhook handler, verify the signature against the raw request body, return 2xx before slow work, and deduplicate by event ID because events can repeat or arrive out of order. Stripe and Hookdeck publish agent skills encoding these rules.

Not for refunds and disputes

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem in plain words

You ask an agent for a Stripe webhook route and it works with one test event, then in real use signature checks fail, the same payment is fulfilled twice, or Stripe keeps retrying because the handler is slow. Stripe's own webhook guide (read October 2026) names these exact failure points.

What Stripe's docs say a handler must do

  • Verify the signature on the raw body. Stripe computes it over the exact bytes it sent. The docs say any change to the raw body, for example a framework that parses JSON first, makes verification fail. Use the official library call (constructEvent in Node, client.construct_event in Python, Stripe::Webhook.construct_event in Ruby) with the raw payload, the Stripe-Signature header and the endpoint's signing secret.
  • Return a 2xx quickly, before complex work. Update the invoice in your accounting system after you have answered. Slow handlers show up as "Timed out" deliveries.
  • Expect duplicates. Log the event IDs you processed and skip repeats. Sometimes two separate Event objects are sent for one thing; then compare data.object ID plus event.type.
  • Do not rely on order. The docs list a subscription creating customer.subscription.created, invoice.created, invoice.paid and charge.created in no guaranteed order, and say not to use created (whole seconds) to order events. Fetch the object from the API if you get a later event first.
  • Process asynchronously. Stripe recommends an async queue so a spike (all subscriptions renewing at month start) does not overwhelm the handler.
  • Frameworks with CSRF checks (Rails, Django) need the webhook route exempted.
  • Signing secrets are per endpoint, and test and live differ. The default time tolerance is 5 minutes; the docs say never set it to 0, which turns the recency check off.
  • Retries: live mode retries for up to three days with exponential backoff; sandbox retries three times over a few hours. A dashboard Resend works for 15 days, stripe events resend <event_id> --webhook-endpoint=<endpoint_id> for 30 days.

Test it locally before trusting it

stripe listen --forward-to localhost:4242/webhook
stripe trigger payment_intent.succeeded

stripe listen prints the signing secret to use for that local listener. Send the same event twice (resend it) and check that the second delivery changes nothing.

Wording to give your agent

"Write the Stripe webhook route. Read the raw body (no JSON parser on this route). Verify with the official library before anything else, return 400 on failure. Store the event ID in a table with a unique constraint and skip events already seen. Return 200 right after enqueueing; do fulfilment in a background job. Do not depend on event order: fetch the object when you need current state. Add a test that posts the same event twice."

Agent skills that encode this

  • Stripe documents agent skills and a plugin: install the Stripe CLI using the installation script for your operating system, then stripe agent setup, or npx skills add https://docs.stripe.com for a manual install (manual installs do not auto-update; npx skills update -y).
  • Hookdeck's open stripe-webhooks skill (MIT, hookdeck/webhook-skills, commit b96e9fb29e) shows verification in Node and Python and recommends its companion webhook-handler-patterns skill: verify first, parse second, handle idempotently third. Hookdeck sells a webhook gateway, so read its advice with that in mind.

Common mistakes

  • Parsing JSON before verifying, or verifying a re-serialised copy of the body.
  • Running fulfilment inside the request, then timing out and getting retried.
  • Treating "delivered once" as a guarantee; no dedupe table.
  • Using the CLI's local secret on the live endpoint (or the reverse).
  • Listening to all event types instead of the few you handle.

What this thread does not show

I did not run these handlers. The rules come from Stripe's documentation as read in October 2026; check the current page and your SDK version before relying on exact function names. For a retried background job that pushes data to Stripe, see the separate thread on idempotency keys.

Sources

Primary sources, opened 18 October 2026: Stripe webhooks guide, plus the hookdeck/webhook-skills repo metadata read through the GitHub API.

  • Confirms (Stripe): signature verification over the unmodified raw body with the Stripe-Signature header and the endpoint secret, using the official library; a quick 2xx before complex work; logging event IDs to skip duplicates, and data.object ID plus event.type for the rare double Event; no guaranteed order and no use of created for ordering; an asynchronous queue; CSRF exemption for the route; separate secrets per endpoint and per test and live key; a default tolerance of five minutes that must never be 0; live retries for up to three days with exponential backoff and sandbox retries three times over a few hours; Dashboard Resend for 15 days and stripe events resend for 30; stripe listen --forward-to printing a signing secret and stripe trigger.
  • Adds: the page also advises IP allowlisting together with signature checks, rolling secrets periodically (with up to 24 hours of overlap), listening only to needed event types, and says new integrations should prefer thin events (the snapshot handler is for tools needing the full Event payload). The page's examples read the payload and parse JSON for a type check before calling construct_event; the verify call itself uses the raw payload.
  • Hookdeck repo: MIT, and the cited commit b96e9fb29e exists (16 October 2026). Its skill contents and the npx skills add line were not reopened here.

Started from a post by @Stripe, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Why does my Stripe webhook fail signature checks or fire twice?
Summary: When implementing a Stripe webhook handler, verify the signature against the raw request body, return 2xx before slow work, and deduplicate by event ID because events can repeat or arrive out of order. Stripe and Hookdeck publish agent skills encoding these rules.
Copy for agent
get the whatworks thread stripe-webhook-handler-raw-body-signature-dedupe and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread stripe-webhook-handler-raw-body-signature-dedupe
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks