Vibe-Code Rescue

No signatures found matching the expected signature for payload

Why it happens

Your code checks each webhook against three things: the raw request body, the Stripe-Signature header and the endpoint secret. Stripe says that at least one of the three is wrong when you see this message.

The most common cause is the wrong endpoint secret. The next most common is a framework that parses the body before your check runs, which changes the bytes Stripe signed.

How to fix it

  1. Find the right secret. For an endpoint made in the Stripe Dashboard, open the endpoint and click Reveal secret. For the Stripe CLI, use the secret printed when you run stripe listen. Both start with whsec_, but they are different values. Do not mix them.
  2. Print the secret your server actually reads and compare it with the one you found. On Vercel, check the value in Settings, Environment Variables for the Production environment, then redeploy so the change takes effect.
  3. Pass the raw body to the check. In a Next.js App Router route, read the body as text. Do not call req.json() first.
    export async function POST(req: Request) {
      const event = stripe.webhooks.constructEvent(
        await (await req.blob()).text(),
        req.headers.get('stripe-signature') as string,
        process.env.STRIPE_WEBHOOK_SECRET as string,
      )
      // handle event
      return new Response('ok')
    }
  4. In Express, register the webhook route before express.json(). If the JSON parser runs first, the body has already been changed.
    app.post('/webhook', /* raw body handler */)
    app.use(express.json())
  5. Print the signature header. It should look like t=xxx,v1=yyy,v0=zzz. If it does not, your code is not reading the header correctly.

When it is not this

Questions

What causes 'No signatures found matching the expected signature for payload'?

At least one of the raw body, the Stripe-Signature header or the endpoint secret passed to constructEvent is wrong. The wrong secret is the most common cause.

Can I use the Stripe CLI secret for my Dashboard endpoint?

No. The CLI prints its own whsec_ secret for stripe listen. A Dashboard endpoint has a different one. Use the secret that belongs to the endpoint sending the event.

Sources

Still broken?

The free health check asks ten questions about your app and shows the three fixes to do first. It runs in your browser.

If you would rather have someone read the code, the fixed-price audit is $497 one-time. It covers security and scaling, with a written report ranked by severity.