“Stripe webhook signature verification failed” means one of the three values you passed to constructEvent() is wrong: the raw request body, the Stripe-Signature header, or the endpoint’s whsec_ signing secret. Stripe’s troubleshooting guide names the secret as the most common cause, ahead of the body. From stripe-node 23.2.0, the error can tell you which one it was.
The usual message reads No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?, and stripe-node throws that same sentence for a wrong secret and for an altered body. It only asks about the body, which sends you to the body parser even when the environment variable holds the Stripe CLI’s secret.
What does Stripe webhook signature verification check?
Stripe joins the delivery timestamp, a full stop and the exact request body, computes an HMAC-SHA256 of that string keyed on the endpoint’s signing secret, and sends the result as a v1 entry in the header next to t, the timestamp. constructEvent() repeats the sum with your copy of the body and your copy of the secret. Only once a v1 entry matches does it look at the clock, and it rejects a delivery whose timestamp is more than 300 seconds old.
That order is useful. Timestamp outside the tolerance zone can only be thrown after the signature matched, so seeing it clears your secret and your body in one go.
Which error points at which input?
The short messages are specific. No stripe-signature header value was provided. and Unable to extract timestamp and signatures from header are about the header: the code reads the wrong header name, or something in front of it dropped the header. No webhook secret value was provided. means the environment variable is unset or blank in this deployment. Webhook payload must be provided as a string or a Buffer means you handed over a parsed object, which is what an Express route receives when express.json() has already run.
That leaves “No signatures found”, which covers both a wrong secret and a changed body.
stripe-node 23.2.0, released on 18 November 2026, splits it. Stripe’s signature documentation now lists three optional debugging entries in the header. secret is the endpoint’s newest signing secret with everything but the prefix and last four characters masked. destination is the endpoint ID, starting we_ or ed_. payload is the last eight hex characters of the SHA-256 digest of the body Stripe signed. When those entries are present, 23.2.0 compares them with what you passed in and reports the difference:
The signing secret you provided is 38 characters long and ends in `PzVt`. However, the signing secret for this destination is 38 characters long and looks like `whsec_****************************Qx7k`.
The SHA-256 hash of the body should end in `4a61bc0c`. However, the SHA-256 hash of the body you provided ends in `c9d370d2`.
The first is a wrong secret, the second an altered body. If both are wrong you get the secret message, because it is checked first.
Two caveats, as of November 2026. The docs say Stripe “might add” these entries and describe them as optional, so do not assume every request carries them. We reproduced both messages by appending the entries to a header built with generateTestHeaderString, and have not measured how many live deliveries include them. They are also outside the HMAC. Anyone forging a request can forge them too, so they are for diagnosis and never for deciding whether to trust a request.
How do you check on an older stripe-node?
Version 23.0.0 dropped Node 18 and changed how tolerance works, so not every project can take 23.2.0 this week. The comparison itself is short enough to paste into a catch block.
import { createHash } from 'node:crypto';
export function diagnose(rawBody: string | Buffer, header: string, secret: string) {
const entries = new Map<string, string>();
for (const part of header.split(',')) {
const i = part.indexOf('=');
const key = part.slice(0, i).trim();
if (i > 0 && !entries.has(key)) entries.set(key, part.slice(i + 1).trim());
}
return {
destination: entries.get('destination') ?? 'not sent',
secretStripeSigned: entries.get('secret') ?? 'not sent',
secretWeUsed: `${secret.length} chars ending ${secret.slice(-4)}`,
bodyHashStripeSigned: entries.get('payload') ?? 'not sent',
bodyHashWeGot: createHash('sha256').update(rawBody).digest('hex').slice(-8),
ageSeconds: Math.floor(Date.now() / 1000) - Number(entries.get('t')),
};
}
Log the result when verification throws. Different endings on the two secret lines mean the wrong secret, different hashes mean the body changed on the way in, and an ageSeconds above 300 is the tolerance check. When the entries come back as “not sent”, work through the next two sections in order.
Which signing secret should the code have?
Every endpoint has its own secret. The same URL registered in test mode and in live mode has two, and stripe listen prints a third for the events the CLI forwards. A .env file copied from a laptop to production therefore carries the CLI’s secret and fails every real delivery.
Then there is whitespace. A trailing newline picked up when the value was piped into a secret store makes a different HMAC key. stripe-node 23.2.0 appends Note: The provided signing secret contains whitespace. to the generic error when that happens, at the very end of the message, after the documentation link.
Rolling a secret is safe if you use the overlap. Stripe can keep the old secret active for up to seven days and sends one v1 entry per active secret, so a handler holding either value keeps verifying until the old one expires.
How do you keep the raw body in Express, Next.js and Workers?
In Express, give the webhook route its own raw parser and register it before express.json().
import express from 'express';
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const endpointSecret = process.env.STRIPE_WEBHOOK_SECRET!;
const app = express();
// Registered before express.json(), with a raw parser of its own.
app.post(
'/webhooks/stripe',
express.raw({ type: 'application/json' }),
(req, res) => {
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(
req.body, // a Buffer, byte for byte what Stripe sent
req.get('stripe-signature') ?? '',
endpointSecret,
);
} catch (err) {
console.error(err instanceof Error ? err.message : err);
res.status(400).send('Signature verification failed');
return;
}
console.log('verified', event.id, event.type);
res.json({ received: true });
},
);
app.use(express.json());
app.listen(4242);
The type option is required, because express.raw() only parses application/octet-stream unless told otherwise. Calling JSON.stringify(req.body) to get a string back does not rescue a parsed body either. Re-serialising does not reproduce the original bytes, and Stripe’s guide lists stripped whitespace, reordered keys and changed encoding among the causes. It is the same rule we covered for Shopify’s HMAC header, with a timestamp added.
On a Web-standard runtime, read the body as text once and use the async verifier.
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
export async function POST(request: Request): Promise<Response> {
const body = await request.text(); // read once, never request.json()
let event: Stripe.Event;
try {
event = await stripe.webhooks.constructEventAsync(
body,
request.headers.get('stripe-signature') ?? '',
process.env.STRIPE_WEBHOOK_SECRET!,
);
} catch (err) {
console.error(err instanceof Error ? err.message : err);
return new Response('Signature verification failed', { status: 400 });
}
console.log('verified', event.id, event.type);
return Response.json({ received: true });
}
That file is a complete Next.js route handler. The async call is what lets the same file run outside Node. The package’s workerd, worker, deno, bun and browser export conditions resolve to a build that signs with Web Crypto, which has no synchronous HMAC, so constructEvent() there throws SubtleCryptoProvider cannot be used in a synchronous context. The async version works on both builds. On a Cloudflare Worker the same calls go inside fetch(request, env), with both secrets read from env.
Anything between Stripe and your code that re-encodes the body breaks verification the same way. The same Stripe guide has a mapping template for API Gateway in front of Lambda.
What causes “Timestamp outside the tolerance zone”?
A valid signature on a delivery that is more than five minutes old by your server’s clock. Retries are not the cause, since Stripe signs every attempt with a fresh timestamp. Three things produce it: verifying after the event has sat in a queue, replaying a captured request in a test, and a drifting clock. Verify on receipt and queue the verified event. In tests, remember that generateTestHeaderString stamps the current time unless you pass timestamp.
Do not reach for a tolerance of 0. Before 23.0.0, constructEvent(body, header, secret, 0) still applied the 300-second default. From 23.0.0 a 0 switches the recency check off, which the changelog lists as a breaking change and Stripe’s docs warn against. A handler that has carried a stray 0 therefore loses its replay check on upgrade. Search for it before bumping the major.
What we would do
Upgrade to 23.2.0 where you can, because the error then names the wrong input whenever Stripe sends the debugging entries. Mount one webhook route ahead of every body parser, call constructEventAsync on every runtime, take each environment’s secret from that environment’s endpoint page, and log the destination entry on failure so you know which endpoint sent the request. Return a 400 when verification fails. Stripe retries live deliveries for up to three days, so a wrong secret fixed within that window should not cost you events.
We would not hand-roll the HMAC unless there is no SDK for the runtime, and we would not treat a verified event as new. Stripe says an endpoint may receive the same event more than once, so key a dedupe table on event.id, the way our Shopify webhook retries write-up does with the webhook id.
We build and maintain payment and checkout integrations for UK retailers, Stripe webhooks included. If yours are failing verification, or passing it and still double-fulfilling orders, that is the kind of thing our ecommerce web development work covers.