Why does my Stripe webhook fail with "No signatures found matching the expected signature for payload"?

Run a free check: FlowWatch signs up, logs in and runs a Stripe test checkout on your app, then scans for exposed keys. You get a shareable report. Run the free check at flowwatch.org

Your app was built with Lovable, Bolt, Cursor or another AI tool. Checkout works, Stripe shows the payment, but the webhook that should upgrade the user returns a 400. In your logs, or in the endpoint's event deliveries in Stripe, you see:

Webhook signature verification failed. Err: No signatures found matching the expected signature for payload.

Stripe's troubleshooting docs say this error means at least one of the three values you passed to constructEvent() is wrong: the raw request body, the Stripe-Signature header, or the endpoint secret (whsec_...). Check them in the order below.

1. You're using the wrong whsec_ secret (most common)

Stripe calls a wrong endpoint secret the most common cause. There are more secrets than people expect:

  • Every endpoint has its own secret. If you have two endpoints (say an old preview URL and your production URL), each one signs with a different secret.
  • Test and live are different. Stripe's webhook docs say that if you use the same endpoint for test and live keys, the secret is different for each one. If you flip to live keys and keep the test whsec_, every live event fails.
  • The Stripe CLI has its own secret. stripe listen prints a whsec_ in your terminal. It only works for events forwarded by the CLI, not for the endpoint you created in the Dashboard (Workbench).

Fix: open the endpoint in Workbench → Webhooks, click to reveal its signing secret, and compare it with the value your code actually reads at runtime. Print the first few characters on the server, because the env var in your hosting dashboard might not be the one your deploy uses. After you change an env var, redeploy so the running code picks it up.

2. Your framework changed the body before you verified it

Stripe signs the exact bytes it sent. Stripe's docs say that if a framework parses or changes the body first (re-serializes JSON, reorders keys, strips whitespace or changes the encoding), verification fails. AI-generated handlers often do JSON.parse first or use a JSON body parser on every route.

What to use, by stack:

  • Supabase Edge Functions (common in Lovable and Bolt apps): read the body with await req.text() and verify it with stripe.webhooks.constructEventAsync(...), passing Stripe.createSubtleCryptoProvider() as the crypto provider. That's how Supabase's official Stripe webhook example does it, because Deno uses the Web Crypto API. Don't call req.json() before verifying.
  • Next.js App Router (route handler): read the body with await request.text() and pass that string to constructEvent. Stripe links a working App Router example from its troubleshooting page.
  • Next.js Pages Router (API route): Stripe's docs say to turn off bodyParser for that route and read the raw buffer.
  • Express: register the webhook route before app.use(express.json()). Express runs middleware in order, so if the JSON parser runs first, the raw body is gone.

3. The signature header isn't reaching your code

Log the header value you pass in. It should look like t=...,v1=.... If it's empty or null, your code is reading the wrong header name, or a proxy in front of your function is dropping it.

Two errors that look similar but aren't

  • A 401 from a Supabase Edge Function before your code even runs. Supabase Edge Functions require a valid JWT in the Authorization header by default, and Stripe doesn't send one. Supabase's function configuration docs say to set verify_jwt = false for the webhook function in supabase/config.toml, or deploy with --no-verify-jwt. You're then relying on the Stripe signature check, so keep it.
  • An old event you replayed by hand fails, but new ones pass. The Stripe-Signature header includes a timestamp. Per Stripe's docs, its libraries reject events more than 5 minutes off by default to stop replay attacks. Resend the event from Stripe instead of replaying a saved copy, and keep your server clock in sync. Don't set the tolerance to 0, which turns the check off.

Don't "fix" it by skipping verification

If you remove the signature check to make the 400 go away, anyone who finds the URL can POST a fake checkout.session.completed and give themselves a paid plan. Stripe's docs recommend always verifying signatures with the official library.

A quick verification pass

  1. In Workbench, open the endpoint's Event deliveries tab and find a failed event. Note the status code: 400 is usually the signature, 401 or 403 is access (see the Supabase note above), and 500 means your handler threw an error after verifying.
  2. Locally, run stripe listen --forward-to <your webhook URL>, put the whsec_ it prints in your local env, then run stripe trigger checkout.session.completed. If that passes, your code is fine and the production secret or body handling is the problem.
  3. In production, resend one test-mode event from the Dashboard and confirm a 2xx response.
  4. Send the same JSON with a missing or fake Stripe-Signature header (for example with curl). Your endpoint should reject it with a 400.
  5. Finish with a full test-mode purchase and check that the user's plan actually changes in your database.

Automating the related checks

FlowWatch runs a real signup, login and Stripe test-mode checkout on your app on a schedule, and emails you if the flow fails and again when it recovers. It only runs test-mode checkouts and refuses to run if it finds live keys. It doesn't read your webhook code or your Stripe logs, so it won't tell you which of the three values is wrong. What it does is tell you when a later deploy breaks checkout again. Start with the free check: flowwatch.org.

Contact: hello@flowwatch.org