Fix “No signatures found matching the expected signature for payload” in Stripe webhooks

Updated

Error messageWebhook signature verification failed. No signatures found matching the expected signature for payload

One of the three inputs to verification is wrong: the endpoint secret (the CLI secret and the dashboard secret are different, and so are test and live), the body (your framework parsed or changed it before verification), or the Stripe-Signature header. Verify against the raw request text with the secret of this exact endpoint.

Check the secret first

This is the most common cause. Both secrets start with whsec_, but stripe listen prints its own secret, different from the one in the dashboard endpoint. Test and live endpoints have different secrets too. Print the value your code uses and compare it, including invisible whitespace.

Next.js App Router

import Stripe from 'stripe'

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)

export async function POST(req: Request) {
  const body = await req.text() // raw text, not req.json()
  const signature = req.headers.get('stripe-signature')!

  let event: Stripe.Event
  try {
    event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!)
  } catch {
    return new Response('Invalid signature', { status: 400 })
  }

  // handle event.type here
  return new Response('ok')
}

Supabase Edge Function

Deno uses the Web Crypto API, so verification is async:

import Stripe from 'npm:stripe'

const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!)
const crypto = Stripe.createSubtleCryptoProvider()

Deno.serve(async (req) => {
  const body = await req.text()
  const signature = req.headers.get('Stripe-Signature')!

  try {
    const event = await stripe.webhooks.constructEventAsync(
      body, signature, Deno.env.get('STRIPE_WEBHOOK_SECRET')!, undefined, crypto
    )
    // handle event.type here
    return new Response('ok')
  } catch {
    return new Response('Invalid signature', { status: 400 })
  }
})

Stripe doesn’t send a Supabase token, so deploy this function with JWT verification off: supabase functions deploy stripe-webhook --no-verify-jwt. Otherwise every delivery fails with 401 before your code runs.

What not to do

When verification keeps failing, AI agents sometimes remove it. After that anyone can send a fake checkout.session.completed and get a paid plan for free. Keep the check, and also store processed event.id values: Stripe can deliver the same event more than once.

Sources