The full message from stripe-node 23.0.1, which also points you to Stripe's signature docs:
No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? If a webhook request is being forwarded by a third-party tool, ensure that the exact request body, including JSON formatting and new line style, is preserved.
stripe-python 16.0.1 raises SignatureVerificationError with the first sentence alone, and stripe-ruby, stripe-php, and stripe-java use the same sentence. stripe-go returns ErrWebhookNoValidSignature, "webhook had no valid signature". The causes and fixes are the same in every language.
What the library checks
Each delivery's Stripe-Signature header looks like t=1793238239,v1=0baa30be.... The library rebuilds the signed payload as the timestamp, a period, and the body you pass, computes an HMAC-SHA256 of it with the secret you pass, and compares the result with each v1 value. Change one byte of the body or one character of the secret and no signature matches. Only after a match does it check that the timestamp is within the tolerance, 5 minutes by default.
Find your cause in one deploy
Log three things in the failing handler, just before verification:
import { createHash } from "node:crypto";
// Add temporarily, just before constructEvent.
const body = req.body;
console.log("body", Buffer.isBuffer(body) ? "Buffer" : typeof body,
body?.length, "content-length", req.headers["content-length"]);
// Want: Buffer (or string), with a length equal to content-length.
console.log("header", String(req.headers["stripe-signature"]).slice(0, 2));
// Want: t=
const secret = process.env.STRIPE_WEBHOOK_SECRET ?? "";
console.log("secret", secret.startsWith("whsec_"), secret !== secret.trim(),
createHash("sha256").update(secret).digest("hex").slice(0, 12));
// Want: true, false, and the fingerprint of the secret you expect.
The secret is logged as a short SHA-256 fingerprint, never as the secret itself. Compute the fingerprint of the secret you expect on your own machine and compare:
# Paste the secret revealed for this endpoint, or the one stripe listen printed.
# read -s keeps it out of your terminal and shell history.
read -rs SECRET && printf '%s' "$SECRET" | shasum -a 256 | cut -c1-12
In Python, compare len(request.body) (Django) or len(request.get_data()) (Flask) with the Content-Length header, and hash the secret with hashlib.sha256.
| What you see | Cause |
|---|
"No signatures found", and the body is a Buffer or untouched string whose length matches Content-Length | The wrong secret |
"No signatures found", and the body is JSON.stringify output or its length differs | The body changed |
| "Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body." | The body was parsed into an object |
| "No webhook payload was provided." | Something consumed the body before your handler, or the route has no body parser at all |
| "No webhook secret value was provided. It should start with `whsec_`" | The secret variable isn't set in this environment. Set this endpoint's secret |
| "No stripe-signature header value was provided." or "Unable to extract timestamp and signatures from header" | The header didn't arrive intact |
| "Timestamp outside the tolerance zone" | The signature matched, but the timestamp is too old: your server's clock is off, or the request was replayed. See why not a tolerance of 0. |
The three causes
Stripe's troubleshooting guide puts the wrong secret first, as the most common cause. A changed body is the other way to get the same message. A damaged header throws different messages, which makes it the easiest to rule out.
The fix in your framework
Every body fix is the same idea: hand the verifier the bytes Stripe sent, and parse JSON only from the event it returns. Here is the change for each stack.
Express
// The webhook route comes first, with a raw-body parser.
app.post(
"/webhooks/stripe",
express.raw({ type: "application/json" }),
(req, res) => {
let event;
try {
event = stripe.webhooks.constructEvent(
req.body, // a Buffer of the exact bytes
req.headers["stripe-signature"],
process.env.STRIPE_WEBHOOK_SECRET,
);
} catch (err) {
return res.status(400).send(`Webhook Error: ${err.message}`);
}
// Handle event, then acknowledge.
res.sendStatus(200);
},
);
// JSON parsing for every other route, registered after the webhook.
app.use(express.json());
Express runs middleware in the order you register it, so app.use(express.json()) above this route parses the body first. To keep one global parser, capture the bytes it read with express.json({ verify: (req, res, buf) => { req.rawBody = buf; } }) and pass req.rawBody to the verifier.
Next.js App Router
// app/api/webhooks/stripe/route.ts
export async function POST(req: Request) {
const body = await req.text(); // the raw body; never req.json()
let event;
try {
event = stripe.webhooks.constructEvent(
body,
req.headers.get("stripe-signature") ?? "",
process.env.STRIPE_WEBHOOK_SECRET!,
);
} catch (err) {
return new Response(`Webhook Error: ${(err as Error).message}`, { status: 400 });
}
return new Response(null, { status: 200 });
}
Route handlers don't parse the body for you. req.json() parses it, and verifying JSON.stringify of the result is the usual cause of this error in App Router projects.
Next.js Pages Router
// pages/api/webhooks/stripe.ts
import type { NextApiRequest, NextApiResponse } from "next";
export const config = { api: { bodyParser: false } };
const rawBody = (req: NextApiRequest) =>
new Promise<Buffer>((resolve, reject) => {
const chunks: Buffer[] = [];
req.on("data", (chunk: Buffer) => chunks.push(chunk));
req.on("end", () => resolve(Buffer.concat(chunks)));
req.on("error", reject);
});
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let event;
try {
event = stripe.webhooks.constructEvent(
await rawBody(req),
req.headers["stripe-signature"] as string,
process.env.STRIPE_WEBHOOK_SECRET!,
);
} catch (err) {
return res.status(400).send(`Webhook Error: ${(err as Error).message}`);
}
res.status(200).end();
}
API routes parse JSON bodies by default. bodyParser: false leaves the stream unread, and the helper collects the bytes the same way Stripe's own Next.js example does.
NestJS
// main.ts
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
rawBody: true,
});
// stripe-webhook.controller.ts
@Controller("webhooks")
export class StripeWebhookController {
@Post("stripe")
handle(
@Req() req: RawBodyRequest<Request>,
@Headers("stripe-signature") signature: string,
) {
const event = stripe.webhooks.constructEvent(
req.rawBody!, // a Buffer; req.body is already parsed
signature,
process.env.STRIPE_WEBHOOK_SECRET!,
);
}
}
rawBody: true keeps Nest's JSON parsing for every route and adds req.rawBody. It depends on the built-in body parser, so don't also pass bodyParser: false.
Django
@csrf_exempt
@require_POST
def stripe_webhook(request):
try:
event = stripe.Webhook.construct_event(
request.body, # raw bytes
request.headers.get("Stripe-Signature", ""),
settings.STRIPE_WEBHOOK_SECRET,
)
except (ValueError, stripe.SignatureVerificationError):
return HttpResponse(status=400)
return HttpResponse(status=200)
request.body is the raw payload. Django REST Framework's request.data is parsed, so verify request.body in the view and don't pass a re-serialized request.data. Stripe can't send a CSRF token, hence csrf_exempt.
Flask
@app.post("/webhooks/stripe")
def stripe_webhook():
try:
event = stripe.Webhook.construct_event(
request.get_data(), # raw bytes, not request.get_json()
request.headers.get("Stripe-Signature", ""),
WEBHOOK_SECRET,
)
except (ValueError, stripe.SignatureVerificationError):
return "", 400
return "", 200
request.get_data() returns the bytes as received. request.get_json() and request.json return a parsed dict.
Rails
class StripeWebhooksController < ApplicationController
protect_from_forgery except: :create
def create
event = Stripe::Webhook.construct_event(
request.body.read, # raw body; params is already parsed
request.headers["Stripe-Signature"],
ENV["STRIPE_WEBHOOK_SECRET"]
)
head :ok
rescue JSON::ParserError, Stripe::SignatureVerificationError
head :bad_request
end
end
params is built from the parsed body, so verify request.body.read. Stripe can't send a Rails CSRF token, so exempt the action.
AWS Lambda behind API Gateway
export const handler = async (event) => {
// A proxy integration passes the body as received, base64-encoded
// when isBase64Encoded is true.
const body = event.isBase64Encoded
? Buffer.from(event.body, "base64")
: event.body;
// Header-name case depends on the API type, so match it case-insensitively.
const signature = Object.entries(event.headers ?? {})
.find(([name]) => name.toLowerCase() === "stripe-signature")?.[1];
try {
stripe.webhooks.constructEvent(body, signature, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
return { statusCode: 400, body: err.message };
}
return { statusCode: 200 };
};
Use a Lambda proxy integration, which leaves the body alone. With a non-proxy integration, verify the rawBody field from Stripe's documented mapping template, not a field built with $input.json('$'), which re-serializes the JSON.
Verify the fix end to end
# Terminal 1: forward test events to your local route.
stripe listen --forward-to localhost:3000/webhooks/stripe
# > Ready! Your webhook signing secret is whsec_...
# Use that secret while the CLI forwards. It isn't your endpoint's secret.
# Or load it straight into the variable your server reads:
export STRIPE_WEBHOOK_SECRET="$(stripe listen --print-secret)"
# Terminal 2: create an event.
stripe trigger payment_intent.succeeded
stripe listen signs forwarded events with its own secret, which stays the same across restarts. Verify CLI-forwarded events with that secret, and switch back to the endpoint's own secret when real deliveries resume. If you keep both around, name the variables so they can't be swapped.
Questions, answered
Why does verification pass locally but fail in production?
Locally, stripe listen signs with its own secret. In production, the endpoint you registered signs with its secret, and test and live modes have different ones. If the deployed secret is right, look for something production has that your laptop doesn't: a proxy, an API gateway, or a framework setting that parses the body.
Can I set the tolerance to 0 to stop the timestamp errors?
No. A tolerance of 0 turns the timestamp check off, which lets anyone replay a captured request. Stripe's docs warn against it. The default is 5 minutes. Sync your server clock with NTP instead; Stripe signs each retry with a new timestamp, so a retried event isn't stale.
Does rolling the webhook secret break retries already in flight?
No. Every delivery attempt is signed when it is sent. If you delay the old secret's expiry, for up to 24 hours, Stripe sends one v1 signature for each active secret, and a match against either passes.
Why does a webhook forwarder or relay cause this error?
A forwarder that parses and re-sends the JSON, or normalizes line endings, changes the bytes Stripe signed. stripe-node's error says so: the exact body, including JSON formatting and newline style, has to reach the verifier unchanged.
Do Flint webhooks have the same failure?
Flint needs the raw body too, but the failures don't share one message. New Flint endpoints sign each delivery with a JWT that you verify with Flint's public keys and your endpoint ID, so there is no shared secret to mix up. The Flint SDK reports a changed body as webhook_body_mismatch, a wrong endpoint ID as webhook_invalid_audience, and an expired token as webhook_token_expired.
On Flint, each failure names itself
Flint is a payments API with orders, tax, and inventory built in. Its webhooks need the raw body as well; no signature scheme can skip that. What changes is the diagnosis. New Flint endpoints sign every delivery with a JWT, checked against Flint's public keys and your endpoint's ID, so there is no shared secret to store, rotate, or confuse with another. The token carries a SHA-256 hash of the body as a separate claim, so a changed body and a wrong endpoint fail different checks, with different codes.
Register an endpoint
Creating an endpoint needs a key with the webhooks.write scope. JWT signing is the default, so the request names only the URL and the events:
curl -X POST https://api.withflintpay.com/v1/webhook-endpoints \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: webhook-endpoint-orders-001" \
-d '{
"url": "https://example.com/webhooks/flint",
"enabled_events": ["order.paid"]
}'
{
"data": {
"webhook_endpoint_id": "whep_1kmn0aExample",
"url": "https://example.com/webhooks/flint",
"signing_methods": ["jwt"],
"enabled_events": ["order.paid"],
"api_version": "default",
"event_sources": ["merchant"],
"status": "active",
"version": 1,
"created_at": "2026-10-28T15:04:05Z",
"updated_at": "2026-10-28T15:04:05Z"
}
}
No secret comes back, because none exists. Save webhook_endpoint_id: it is the audience your verifier expects, and it stays the same when you change the URL.
Verify a delivery
The SDK fetches and caches Flint's public keys, checks the token's signature, issuer, audience, and lifetime, then compares the body hash with the bytes you received. Answering with the error code costs nothing secret and makes the next step readable from the API:
import express from "express";
import { Client, SdkError } from "@flintpay/node";
const app = express();
const flint = new Client({ apiKey: process.env.FLINT_API_KEY });
// Raw body on this route, exactly as with Stripe.
app.post("/webhooks/flint", express.raw({ type: "application/json" }), async (req, res) => {
let verified;
try {
verified = await flint.verifyWebhookAsync(req.body, req.headers, {
endpointIds: [process.env.FLINT_WEBHOOK_ENDPOINT_ID], // whep_..., not a secret
});
} catch (error) {
if (!(error instanceof SdkError)) return res.sendStatus(500);
// Flint's keys couldn't be loaded: answer 5xx so Flint retries.
if (error.code === "webhook_jwks_unavailable") return res.status(503).send(error.code);
// webhook_body_mismatch, webhook_invalid_audience, webhook_token_expired, ...
return res.status(400).send(error.code);
}
// Record verified.event durably, then acknowledge.
res.sendStatus(200);
});
Each delivery also carries a Flint-Webhook-Endpoint-Id header. When you see webhook_invalid_audience, compare it with the ID you configured; neither value is secret, so you can log both.
Test it without a CLI secret
A test event goes through the same signing path as a real delivery, to the registered endpoint, and the response reports what your server answered, including the first 4 KB of its response body. Here the handler above caught a body that middleware had parsed:
curl -X POST https://api.withflintpay.com/v1/webhook-endpoints/whep_1kmn0aExample/test-events \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: webhook-test-order-paid-001" \
-d '{"event_type": "order.paid"}'
{
"data": {
"webhook_event_id": "whev_1kmn0aExample",
"webhook_delivery_id": "wdel_1kmn0aExample",
"webhook_delivery_attempt_id": "watt_1kmn0aExample",
"attempt_number": 1,
"attempt_status": "failed",
"delivery_status": "failed",
"delivery_trigger": "test_event",
"status_code": 400,
"error_category": "webhook_http_4xx",
"error_summary": "The webhook endpoint rejected the delivery.",
"retryable": false,
"response_body_excerpt": "webhook_body_mismatch",
"duration_milliseconds": 38
}
}
Fix the route, send another test event, and attempt_status comes back delivered. Real deliveries record the same fields on every attempt, which GET /v1/webhook-deliveries/{webhook_delivery_id}/attempts returns, and a failed delivery can be resent once the handler is fixed.
If a receiver must use a shared secret, create its endpoint with signing_methods: ["hmac"] and verify the Standard Webhooks signature it sends, as Verify an HMAC delivery shows. The webhooks guide covers retries, deduplication, and recovery, and the SDK guide lists every verification error code.