Stripe guide

Stripe webhook signature verification failed

Every reason Stripe’s constructEvent rejects a webhook, most common first, and how to fix each one.

Updated 9 November 2026 · 7 minute read

The error is usually one of these:

No signatures found matching the expected signature for payload.
Are you passing the raw request body you received from Stripe?
Timestamp outside the tolerance zone

Stripe signs timestamp + "." + raw body with your endpoint's secret and sends the result in the Stripe-Signature header as t=…,v1=…. Verification fails when any one of those three inputs differs from what Stripe used. Here are the causes, most common first.

1. The body was parsed before you verified it

By far the most common cause. A JSON parser turns the body into an object; serialising it again changes whitespace, key order or unicode escapes, so the bytes no longer match what Stripe signed. The fix is to verify against the raw body.

Express

// Before app.use(express.json()), or the global parser runs first
app.post('/webhooks/stripe', express.raw({ type: 'application/json' }), handler);

Next.js App Router

export async function POST(req) {
    const body = await req.text();   // not req.json()
    const event = stripe.webhooks.constructEvent(body, req.headers.get('stripe-signature'), secret);
}

Next.js Pages Router

export const config = { api: { bodyParser: false } };
// then read the request stream into a Buffer and pass that

Laravel and plain PHP

$payload = $request->getContent();          // Laravel
$payload = file_get_contents('php://input');  // plain PHP

Never json_encode($request->all()).

Python

payload = request.get_data()   # Flask
payload = request.body         # Django

2. The wrong secret

  • An API key instead of the signing secret. sk_test_… and rk_… are API keys. The webhook secret starts with whsec_ and lives under Developers → Webhooks → your endpoint → Signing secret.
  • Another endpoint's secret. Every endpoint has its own secret, and test mode and live mode differ.
  • The Stripe CLI's secret. stripe listen prints a separate whsec_ that only works for events it forwards. Events from your dashboard endpoint need that endpoint's secret.
  • Connect events. Events from connected accounts go to a Connect endpoint, which has its own secret.
  • Whitespace. A trailing newline or quote copied into .env or a secrets manager. Trim the value and check its length.

3. The timestamp is too old

Stripe's libraries reject signatures more than 5 minutes old to stop replay attacks. You see this when:

  • The server clock is wrong. Turn on NTP.
  • You resend an old captured request, for example from a log or a webhook debugger. The original signature still carries the original time.
  • A queue held the request before your code verified it. Verify on arrival, then queue.

For replays during development, pass a larger tolerance (the fourth argument to constructEvent in Node and PHP, tolerance= in Python). Keep the default in production.

  • Read Stripe-Signature case-insensitively. In PHP it is $_SERVER['HTTP_STRIPE_SIGNATURE'].
  • Some proxies and API gateways drop or rename unfamiliar headers. Log the headers your app actually receives.
  • Don't hand-build or edit the header in tests. Use the library's test helper (stripe.webhooks.generateTestHeaderString in Node) or a real event.

5. Something rewrote the body on the way

Less common, but hard to spot: a proxy that re-encodes the charset, a framework that trims the body, a gateway that decompresses and re-compresses, or middleware that converts line endings. Compare the byte length of the body you verify with the Content-Length Stripe sent.

How to find which one it is

Libraries only say the check failed. To narrow it down by hand, capture the exact request Stripe sent and try each cause in turn against it.

SlingHook does that for you. Point your Stripe endpoint at a SlingHook URL and save the whsec_ secret on it. When a signature fails, the inspector tells you which cause it was: an API key in place of the signing secret, a timestamp outside the tolerance, a re-encoded body, or a malformed header, and what to change. You can test another secret against the captured request without saving it, and replay the request to your local handler once you've fixed it.

New to this setup? Start with how to test Stripe webhooks locally.

Catch your Stripe webhooks in one place.

Free plan, no card needed. Your URL is ready as soon as you sign up.

Get a free endpoint