Stripe webhook signature verification failed (400): causes and fix
Updated · by Zane
What the 400 means
When Stripe sends a webhook, it signs the raw request body together with a timestamp. The signature goes in a request header called Stripe-Signature. Your function takes the same body and the same secret, computes the signature itself, and compares. If they differ, it refuses the request and returns 400.
The secret is specific to one endpoint. It starts with whsec_. Every endpoint has its own, and test mode and live mode have separate endpoints, so they have separate secrets too.
This is the second link in the chain I describe in the guide on Stripe payments that do not upgrade the user. Money moved, but your app refused to believe the message about it.
Step 1: read the log line
In the Stripe Dashboard, open Developers, then Webhooks, then your endpoint, and look at the failed delivery. Some accounts show this under Workbench. You will see a 400 response. Then open your function's own log. In Supabase that is Edge Functions, then your function, then Logs.
In my demo project I set STRIPE_WEBHOOK_SECRET to a wrong value on purpose. The function returned 400 and logged this. The text after the colon is Stripe's library message, so yours should read the same:
[webhook] signature verification failed: No signatures found matching the expected signature for payloadThat message does not say which of the causes below you have. It only says the two signatures differ. The causes are listed from most common to least.
Cause 1: the secret came from somewhere else
The usual sources of a wrong value:
- The secret that
stripe listenprinted in your terminal. It only works for events that tool forwards to your machine. - The secret of a different endpoint, for example an old one you deleted.
- A test mode secret in a live mode setup, or the other way round. The two modes share nothing.
How to get the right one
- Open the Stripe Dashboard, then Developers, then Webhooks. Check the test or live switch matches the event that failed.
- Click the endpoint that points at your function.
- Next to Signing secret, click Reveal and copy the value.
- In Supabase, open Edge Functions, then Secrets, and set
STRIPE_WEBHOOK_SECRETto it. - Redeploy the function.
Cause 2: the endpoint or secret changed
If you deleted and recreated the endpoint, the new one has a new secret. The same happens if you rolled the secret. The environment variable still holds the old value, and every delivery fails from that moment on. The fix is the same: copy the current value and update the variable.
Cause 3: the variable changed but the function did not
I would check two things here. First, did you redeploy after changing the secret? A running function keeps the values it started with. Second, look at the value itself. A stray space, a quote character or a line break copied along with it makes the secret different even though it looks right. Paste it again and make sure there is nothing around it.
Cause 4: the body was changed before the check
The signature covers the exact bytes Stripe sent. If your code parses the body as JSON and then turns it back into text, spacing and key order can change, and the check fails even with the right secret. Some web frameworks also parse the body for you before your code runs.
// Wrong: the body is parsed, then turned back into text.
// The text is no longer byte-for-byte what Stripe signed.
const payload = await req.json();
const body = JSON.stringify(payload);
event = await stripe.webhooks.constructEventAsync(body, signature!, secret, undefined, cryptoProvider);Read the body once as raw text, verify it, and only then work with the parsed event. That is what the function below does.
Cause 5: the wrong kind of key
Stripe gives you three different values that look alike. The webhook signing secret starts with whsec_. The secret API key starts with sk_. The publishable key starts with pk_. Only the first one belongs in STRIPE_WEBHOOK_SECRET. The other two do different jobs.
Cause 6: the wrong verification call for your runtime
Supabase Edge Functions run on Deno. In that kind of runtime the usual synchronous constructEvent is not available. Use the async version, constructEventAsync, and pass a SubtleCrypto provider. This is the shape my demo project uses:
const cryptoProvider = Stripe.createSubtleCryptoProvider();
Deno.serve(async (req) => {
const signature = req.headers.get("Stripe-Signature");
const body = await req.text(); // raw text, not req.json()
let event: Stripe.Event;
try {
event = await stripe.webhooks.constructEventAsync(
body,
signature!,
Deno.env.get("STRIPE_WEBHOOK_SECRET")!,
undefined,
cryptoProvider,
);
} catch (err) {
console.error("[webhook] signature verification failed:", (err as Error).message.split("\n")[0]);
return new Response("Webhook signature verification failed", { status: 400 });
}
// ...handle the event
});A related error: timestamp outside the tolerance zone
You may also see this message from the same library:
Timestamp outside the tolerance zoneThe signature includes a timestamp, and by default the library accepts a difference of 5 minutes. You see this when someone replays a request captured long ago. Using Resend in the Stripe Dashboard avoids it, because Resend creates a fresh signature.
Do not turn verification off
It is tempting to delete the check so the 400 goes away. Without it, anyone who learns your function URL can post a fake payment event and your app will act on it. The signature is the only proof the message came from Stripe. Fix the secret, keep the check.
Test the fix
- Stay in Stripe test mode. Do not test with a real card.
- Open the failed event in the endpoint's list and click Resend.
- Confirm the response is now 200 and the function log shows the event was received.
- If the event is meant to change data, check the database row as well. A 200 on its own is not proof, which the upgrade guide covers.
If the webhook now verifies but the data still does not change, read Supabase update returns no error but nothing changes. If the failures began right after going live, test and live mode are probably mixed. The test versus live guide lists everything that must change together. I also walk through a payment fix end to end in the videos on the home page.
FAQ
Can I skip verification while testing?
I would not. It is easy to forget to turn it back on. Without verification, anyone who finds your webhook URL can send a fake paid event and upgrade an account for free. Fix the secret instead; it takes a few minutes.
Why does it work locally with stripe listen but fail in production?
The Stripe command line tool prints its own signing secret when you run stripe listen. That secret only works for events it forwards. Your production endpoint in the Stripe Dashboard has a different whsec_ value, and that is the one your deployed function needs.
I rotated the secret and now everything fails. What do I do?
Copy the new signing secret from the endpoint in Stripe, update STRIPE_WEBHOOK_SECRET in your function's secrets, and redeploy. Then resend the events that failed while the old value was in place.
Checklist
Still stuck?
Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.
Related guides
- Bolt.new Stripe webhook not working after deploying to Netlify (404 or no upgrade)
- Lovable custom domain with Cloudflare: fix "too many redirects" (ERR_TOO_MANY_REDIRECTS)
- Lovable custom domain not working: stuck pending, no SSL, or www fails
- Lovable email verification not working: signup confirmation emails not arriving
- Lovable Google sign in showing redirect_uri_mismatch or an unverified app warning
- Base44 custom domain stuck on Pending verification
- Base44 payment succeeded, but the customer was not upgraded
- Lovable Stripe checkout: "Edge Function returned a non-2xx status code"
- Lovable password reset link not working or sending users to the wrong page
- Replit custom domain not working: stuck on Verifying or showing a blank page
- Is your Supabase data public? A two-minute RLS check
- Blank white page after publishing your AI-built app
- “No such price” when going live: Stripe test and live mode mixed up
- Stripe payment succeeded but the user is still on the Free plan
- Subscription cancelled in Stripe but the user still has the paid plan
- Login sends users to localhost or the preview URL after publishing
- Supabase update returns no error but nothing changes