# Stripe webhooks: fix "No signatures found matching the expected signature"

> Why Stripe's constructEvent throws "No signatures found matching the expected signature for payload" and the fix for Express, Next.js, NestJS and Workers.

- Published 2026-11-29, updated 2026-11-29
- URL: https://softreuse.com/guides/stripe-signature-verification-error-nodejs

**Short answer:** `stripe.webhooks.constructEvent` must receive the **raw request body exactly as Stripe sent it** and **this endpoint's** `whsec_` signing secret. The error almost always means your framework parsed the JSON before you verified it, or the secret belongs to another endpoint, mode or `stripe listen` session.

## What the error means

Stripe signs each delivery with `Stripe-Signature: t=<timestamp>,v1=<signature>`, where the signature is HMAC-SHA256 of `<timestamp>.<raw body>` keyed with the endpoint's secret. `constructEvent` recomputes it and throws `StripeSignatureVerificationError` when no `v1` matches:

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

Recent versions of stripe-node add a note when your secret contains whitespace, and throw a different message ("Webhook payload must be provided as a string or a Buffer…") when you pass a parsed object.

## The causes, most common first

1. **The body was parsed and re-serialised.** `express.json()`, `request.json()`, NestJS's default body parser and similar turn the body into an object. `JSON.stringify` of it differs from what Stripe signed (whitespace, key order, unicode escapes), so the HMAC can't match.
2. **The wrong secret.** Every Dashboard endpoint has its own secret, test and live mode differ, and `stripe listen` prints a separate one for each session. Your API key (`sk_…`) is not the signing secret.
3. **Whitespace in the secret.** A trailing newline or space in the environment variable.
4. **Something rewrote the body on the way.** A proxy or forwarding tool that re-formats JSON or changes line endings.

Not sure which? Paste the secret, the `Stripe-Signature` header and the body into the [webhook signature debugger](https://softreuse.com/tools/webhook-signature-debugger). It runs in your browser and tells you whether the body was re-serialised, a newline changed, or the secret is wrong.

## The fix for your framework

**Next.js App Router**

```ts
// app/api/webhooks/stripe/route.ts
import Stripe from "stripe";

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

export async function POST(request: Request) {
  const body = await request.text(); // not request.json()
  const signature = request.headers.get("stripe-signature") ?? "";
  let event: Stripe.Event;
  try {
    event = stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET!.trim());
  } catch (err) {
    return new Response(`Webhook error: ${(err as Error).message}`, { status: 400 });
  }
  // store event.id with a unique constraint, answer 2xx, then process
  return new Response(null, { status: 200 });
}
```

**Next.js Pages Router**: export `config = { api: { bodyParser: false } }` from the API route and read the request stream into a Buffer before calling `constructEvent`.

**Express**: give the webhook route the raw parser, and register it **before** any global `express.json()`:

```ts
app.post("/webhooks/stripe", express.raw({ type: "application/json" }), (req, res) => {
  const event = stripe.webhooks.constructEvent(req.body, req.headers["stripe-signature"] as string, secret); // req.body is a Buffer
  res.sendStatus(200);
});
app.use(express.json()); // the rest of the app
```

**NestJS**: create the app with `NestFactory.create(AppModule, { rawBody: true })` and verify `req.rawBody`.

**Cloudflare Workers, Deno and other Web Crypto runtimes**: `constructEvent` needs Node's crypto. Use the async variant:

```ts
const event = await stripe.webhooks.constructEventAsync(body, signature, secret, undefined, Stripe.createSubtleCryptoProvider());
```

## Related errors

| Message | Cause |
|---|---|
| `Timestamp outside the tolerance zone` | The `t=` timestamp is more than 300 seconds (the default) from your clock: an old event replayed, verification delayed by a queue, or a wrong server clock. |
| `No stripe-signature header value was provided.` | The header was dropped, often by a proxy, or the request didn't come from Stripe. |
| `Unable to extract timestamp and signatures from header` | The header value is truncated or isn't Stripe's. |
| `Webhook payload must be provided as a string or a Buffer…` | You passed a parsed object. Pass the raw body. |

## After it verifies

A valid signature doesn't stop the next problems: Stripe delivers **at least once**, so the same event can arrive twice; a slow handler makes Stripe time out and retry; and a crash halfway leaves work half done. [Stripe webhooks in Node.js: verify, deduplicate and retry](https://softreuse.com/guides/stripe-webhooks-nodejs-idempotency-retries) covers that part, and [Reliable Webhooks](https://softreuse.com/products/reliable-webhooks) implements it: verification with the raw body, deduplication on the event id, storage before answering, and retries with a dead-letter state.

## Sources

- [Stripe: Resolve webhook signature verification errors](https://docs.stripe.com/webhooks/signature)
- [stripe-node: Webhooks.js](https://github.com/stripe/stripe-node/blob/master/src/Webhooks.ts)

## Frequently asked questions

### What does "No signatures found matching the expected signature for payload" mean?

stripe-node recomputed the HMAC-SHA256 of the timestamp and the body you passed with the secret you passed, and it matched none of the v1 signatures in the Stripe-Signature header. Either the body is not the exact bytes Stripe sent (most often it was parsed as JSON and serialised again), or the secret is not this endpoint's signing secret.

### Why does it work with the Stripe CLI but not in production (or the other way round)?

Each has its own signing secret. stripe listen prints a whsec_ secret for that CLI session; every endpoint in the Dashboard has another; and test mode and live mode endpoints differ. Use the secret of the endpoint that actually sent the event.

### How do I get the raw body in the Next.js App Router?

Call await request.text() in the route handler and pass that string to stripe.webhooks.constructEvent. Don't call request.json() first: once parsed and re-serialised, the bytes no longer match the signature.

### What does "Timestamp outside the tolerance zone" mean?

The signature may be fine, but the t= timestamp in Stripe-Signature is more than the tolerance (300 seconds by default) away from your server's clock. It happens when replaying an old event, when a queue delays verification, or when the server clock is wrong.

### Why does constructEvent fail on Cloudflare Workers or edge runtimes?

constructEvent is synchronous and needs Node's crypto. On runtimes with only Web Crypto, use await stripe.webhooks.constructEventAsync(body, signature, secret, undefined, Stripe.createSubtleCryptoProvider()).
