Skip to content
HooktierDocs

Stripe: "No signatures found matching the expected signature for payload"

Your Stripe webhook handler rejects events, and the log shows one of these errors:

StripeSignatureVerificationError: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Webhook payload must be provided as a string or a Buffer (https://nodejs.org/api/buffer.html) instance representing the _raw_ request body.Payload was provided as a parsed JavaScript object instead.
SignatureVerificationError: No signatures found matching the expected signature for payload
webhook had no valid signature
Webhook signature verification failed. Err: No signatures found matching the expected signature for payload.

The first two come from stripe-node, the third from stripe-python and the fourth from stripe-go. The fifth is the example that Stripe’s own troubleshooting page shows. They all mean the same thing: the signature that your code computed does not match any v1 signature in the Stripe-Signature header.

The signature depends on three inputs: the raw request body, the Stripe-Signature header and the endpoint’s signing secret. One of them is wrong. This page lists the causes in the order you should check them.

Stripe sends a Stripe-Signature header with each event:

Stripe-Signature: t=1760090000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd
  • t is the Unix time when Stripe signed the event.
  • v1 is the hex HMAC-SHA256 of the string <t>.<raw body>, keyed with the endpoint’s signing secret. The libraries use the whole secret as the key, whsec_ prefix included.
  • The header can carry more than one v1 value, for example while you roll the secret. The signature is valid when any v1 value matches.
  • Test events also carry a fake v0 signature. Ignore every scheme that is not v1.

Stripe’s libraries also reject an event whose t is too old. The default tolerance is five minutes (300 seconds). Stripe makes a new timestamp and signature for every delivery attempt, retries included.

Stripe’s own documentation names this as the most common cause. Each of these has its own secret, and all of them start with whsec_:

  • every webhook endpoint in the Dashboard,
  • the Stripe CLI (stripe listen),
  • the test version and the live version of the same endpoint.

Check that the secret in your environment belongs to the endpoint that sends the event:

  1. For a Dashboard endpoint, open the endpoint in the Dashboard and copy its signing secret.
  2. For the CLI, copy the secret that stripe listen prints in the terminal when it starts, or run stripe listen --print-secret.
  3. Compare the first and last characters of that secret with the value your process reads.

Do not verify CLI-forwarded events with a Dashboard secret, or the reverse.

A secret with a trailing newline or space also fails. This happens when the value comes from a file or a copy and paste. stripe-node adds a note to the error when the secret contains whitespace: “The provided signing secret contains whitespace.”

2. A body parser changed the body before verification

Section titled “2. A body parser changed the body before verification”

Stripe signs the exact body it sends, and any change to it makes the verification fail. Some frameworks parse or change the body before your code sees it: they reorder keys, strip whitespace, convert it to JSON or change its encoding. Passing a parsed object is invalid. Re-serializing JSON, for example with JSON.stringify(req.body), can change its bytes and break verification. Pass the original raw body instead.

stripe-node reports a parsed object with the second error above (“Payload was provided as a parsed JavaScript object instead”). A re-serialized string gives the first error if re-serialization changes the body bytes.

Pass the raw body. The recipes below show how in each framework.

Register the webhook route with express.raw() before any global express.json(). When express.json() runs first, it consumes the body and express.raw() gets nothing to read.

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();
// 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, not a parsed object
req.headers["stripe-signature"],
endpointSecret,
);
} catch (err) {
console.error(`Stripe signature check failed: ${err.message}`);
return res.sendStatus(400);
}
// Queue the event for processing, then answer quickly.
console.log(`Received ${event.type} ${event.id}`);
res.sendStatus(200);
});
// JSON parsing for every other route comes after.
app.use(express.json());
app.listen(3000);

A route handler receives a standard Request. Read the body with request.text(), never with request.json().

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();
const signature = request.headers.get("stripe-signature");
let event: Stripe.Event;
try {
event = stripe.webhooks.constructEvent(body, signature!, process.env.STRIPE_WEBHOOK_SECRET!);
} catch (err) {
console.error(`Stripe signature check failed: ${(err as Error).message}`);
return new Response("Invalid signature", { status: 400 });
}
console.log(`Received ${event.type} ${event.id}`);
return new Response(null, { status: 200 });
}

Cloudflare Workers and other Web Crypto runtimes

Section titled “Cloudflare Workers and other Web Crypto runtimes”

For runtimes that use Web Crypto, call constructEventAsync with Stripe.createSubtleCryptoProvider(). Cloudflare Workers also supports Node crypto when Node compatibility is enabled.

import Stripe from "stripe";
export default {
async fetch(request: Request, env: { STRIPE_SECRET_KEY: string; STRIPE_WEBHOOK_SECRET: string }) {
const stripe = new Stripe(env.STRIPE_SECRET_KEY);
const body = await request.text();
const signature = request.headers.get("stripe-signature");
try {
const event = await stripe.webhooks.constructEventAsync(
body,
signature!,
env.STRIPE_WEBHOOK_SECRET,
undefined,
Stripe.createSubtleCryptoProvider(),
);
console.log(`Received ${event.type} ${event.id}`);
return new Response(null, { status: 200 });
} catch (err) {
return new Response("Invalid signature", { status: 400 });
}
},
};

Use request.get_data() (the raw bytes). Do not use request.json or request.get_json(). request.data is empty when the request has a form content type, so get_data() is the safer choice. (This is Flask behaviour, not a Stripe rule.)

import os
import stripe
from flask import Flask, request
app = Flask(__name__)
endpoint_secret = os.environ["STRIPE_WEBHOOK_SECRET"]
@app.post("/webhooks/stripe")
def stripe_webhook():
try:
event = stripe.Webhook.construct_event(
request.get_data(), request.headers.get("Stripe-Signature"), endpoint_secret
)
except ValueError:
return "Invalid payload", 400
except stripe.SignatureVerificationError as e:
app.logger.warning("Stripe signature check failed: %s", e)
return "Invalid signature", 400
app.logger.info("Received %s %s", event["type"], event["id"])
return "", 200

Read the body once with io.ReadAll and pass those bytes. A size limit protects the handler.

package main
import (
"io"
"log"
"net/http"
"os"
"github.com/stripe/stripe-go/v87/webhook"
)
func stripeWebhook(w http.ResponseWriter, r *http.Request) {
payload, err := io.ReadAll(http.MaxBytesReader(w, r.Body, 1<<20))
if err != nil {
http.Error(w, "cannot read body", http.StatusBadRequest)
return
}
event, err := webhook.ConstructEvent(payload, r.Header.Get("Stripe-Signature"), os.Getenv("STRIPE_WEBHOOK_SECRET"))
if err != nil {
log.Printf("stripe webhook rejected: %v", err)
http.Error(w, "invalid webhook", http.StatusBadRequest)
return
}
log.Printf("received %s %s", event.Type, event.ID)
w.WriteHeader(http.StatusOK)
}
func main() {
http.HandleFunc("POST /webhooks/stripe", stripeWebhook)
log.Fatal(http.ListenAndServe(":3000", nil))
}

stripe-go also returns an error when the event’s API version is incompatible with the library (it compares release trains): “received event with API version …, but stripe-go … expects API version …”. That is not a signature failure. Fix it by creating the endpoint with the library’s API version, or by upgrading the library.

3. Something between Stripe and your code changed the body

Section titled “3. Something between Stripe and your code changed the body”

A proxy, an API gateway, a serverless adapter or a forwarding tool can re-encode the body. Common changes are re-indented JSON, changed line endings, a decoded and re-encoded character set, or a body converted to base64. stripe-node says so in its error text: “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.”

To find the layer that changes the body:

  1. Record the body length and SHA-256 immediately before and after the suspected layer for one test request.
  2. Compare those measurements for that same request.
  3. Different measurements show that the body changed between those points.

Do not compare a real delivery with a Stripe CLI sample: they are different requests with different bodies, so the comparison proves nothing.

4. The Stripe-Signature header does not reach your code

Section titled “4. The Stripe-Signature header does not reach your code”

These errors mean the header is missing or empty:

No stripe-signature header value was provided.
webhook has no Stripe-Signature header

Check that a proxy does not strip unknown headers. In Node, read the lowercase name (req.headers["stripe-signature"]), because Node lowercases incoming header names.

This error means the header is there but has no t value that can be parsed:

Unable to extract timestamp and signatures from header

Pass the header value exactly as received. Do not split it, trim parts of it or decode it.

Timestamp outside the tolerance zone
timestamp wasn't within tolerance

stripe-python adds the timestamp: Timestamp outside the tolerance zone (<t>).

The signature matched, but t is older than the tolerance (five minutes by default). Stripe signs each retry again with a new timestamp, so the age comes from your side. There are two usual reasons:

  • The server clock is wrong. Run NTP on the host.
  • Your code verifies the event late, for example in a background job that reads from a queue. Verify the signature when the request arrives, then queue the verified event.

Do not set the tolerance to zero to make the error go away. Stripe’s documentation warns that a tolerance of 0 turns the recency check off, and that check is what stops an attacker from replaying a captured event.

6. You rolled the secret and the old one expired

Section titled “6. You rolled the secret and the old one expired”

When you roll an endpoint’s secret, you can expire the old secret at once or keep it valid for up to 24 hours. While both secrets are valid, Stripe makes one signature per secret, so the header has two v1 values. After the old secret expires, a server that still has the old secret fails every event.

Deploy the new secret before the old one expires. If you verify by hand, check every v1 value, not only the first.

Use this when you cannot use an official library, or to prove which input is wrong. It follows the same steps as the libraries.

import crypto from "node:crypto";
// Returns true when one v1 signature in the header matches and the timestamp is fresh.
export function verifyStripeSignature(rawBody, header, secret, toleranceSeconds = 300) {
// An empty key would let anyone compute a valid signature.
if (typeof secret !== "string" || secret.length === 0) return false;
if (typeof header !== "string" || header.length === 0) return false;
let timestamp = null;
const signatures = [];
for (const part of header.split(",")) {
const [key, value] = part.split("=");
if (key === "t") timestamp = Number.parseInt(value, 10);
if (key === "v1" && typeof value === "string" && /^[0-9a-f]{64}$/i.test(value)) {
signatures.push(value);
}
}
if (!Number.isInteger(timestamp) || signatures.length === 0) return false;
const expected = crypto
.createHmac("sha256", secret) // the whole secret, whsec_ included
.update(`${timestamp}.${rawBody}`, "utf8")
.digest();
const matched = signatures.some((sig) => {
const given = Buffer.from(sig, "hex");
return given.length === expected.length && crypto.timingSafeEqual(given, expected);
});
if (!matched) return false;
return Math.floor(Date.now() / 1000) - timestamp <= toleranceSeconds;
}

In this function, toleranceSeconds = 0 rejects timestamps older than the current second. Stripe warns against zero tolerance because some SDKs disable recency checking. Keep the default 300-second tolerance.

Compare the expected signature with each received v1 signature in constant time, as Stripe’s documentation asks (crypto.timingSafeEqual, Python hmac.compare_digest, Go hmac.Equal). A plain string comparison leaks timing information.

  1. The secret belongs to this endpoint, in this mode (test or live), and has no whitespace.
  2. The code passes the raw bytes of the body, not a parsed or re-serialized object.
  3. No proxy or adapter changes the body or drops the Stripe-Signature header.
  4. The verification runs when the request arrives, and the server clock is correct.
  5. After a secret roll, the new secret is deployed before the old one expires.

Checked on 2026-10-10.

  • Stripe: Receive Stripe events in your webhook endpoint: sections “Verify webhook signatures manually”, “Verify webhook signatures with official libraries”, “Preventing replay attacks”, “Retrieving your endpoint’s secret” and “Roll endpoint signing secrets periodically”
  • Stripe: Manage webhook endpoints: sections “Resolve signature verification errors”, “Check the endpoint secret”, “Check the request body” and “Check the signature header” (the old /webhooks/signature URL redirects here)
  • Flask: Request.get_data
  • Stripe CLI: stripe listen (--print-secret)
  • stripe-node 23.0.0 source, Webhooks.js: error messages, the whitespace note, signed content `${timestamp}.${payload}` (repository)
  • stripe-python 16.0.0 source, _webhook.py: error messages (repository)
  • stripe-go v87.0.0 source, webhooks.go and webhook/client.go: error values, the API version check (repository)