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 (
constructEventin Node,client.construct_eventin Python,Stripe::Webhook.construct_eventin Ruby) with the raw payload, theStripe-Signatureheader 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.objectID plusevent.type. - Do not rely on order. The docs list a subscription creating
customer.subscription.created,invoice.created,invoice.paidandcharge.createdin no guaranteed order, and say not to usecreated(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, ornpx skills add https://docs.stripe.comfor a manual install (manual installs do not auto-update;npx skills update -y). - Hookdeck's open
stripe-webhooksskill (MIT, hookdeck/webhook-skills, commit b96e9fb29e) shows verification in Node and Python and recommends its companionwebhook-handler-patternsskill: 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-Signatureheader and the endpoint secret, using the official library; a quick 2xx before complex work; logging event IDs to skip duplicates, anddata.objectID plusevent.typefor the rare double Event; no guaranteed order and no use ofcreatedfor 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 andstripe events resendfor 30;stripe listen --forward-toprinting a signing secret andstripe 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 addline were not reopened here.
Started from a post by @Stripe, packaged by the editor. Original post