Developers
Webhook signatures
Check that a webhook really came from SaaSFunnels before you act on it.
Where to find itSettingsIntegrationsWebhook
SaaSFunnels signs every webhook it sends to your endpoints, including test sends. Check the signature before you trust the body.
Get your signing secret
When you add an endpoint in Settings → Integrations → Webhook with Add endpoint, SaaSFunnels shows a one-time webhook signing secret. Copy it and store it on the server that receives the webhooks. Each endpoint has its own secret.
Headers
| Header | Value |
|---|---|
x-saasfunnels-signature | v1= and a lowercase hex HMAC-SHA256 |
x-saasfunnels-timestamp | ISO-8601 time the request was signed |
x-saasfunnels-delivery-id | A unique ID for this delivery |
x-saasfunnels-event | What happened, such as saasfunnels.funnel.lead.v1, or saasfunnels.webhook.test for a test send |
Check the signature
- Read the raw request body as text. Don't parse and re-serialize it first.
- Build the string
<timestamp>.<raw body>, using thex-saasfunnels-timestampvalue. - Compute an HMAC-SHA256 of that string with your signing secret, as lowercase hex.
- Compare
v1=<your result>withx-saasfunnels-signatureusing a constant-time comparison. - Reject requests whose timestamp is more than a few minutes old.
import { createHmac, timingSafeEqual } from "node:crypto";
export function isFromSaaSFunnels(rawBody, headers, secret) {
const timestamp = headers["x-saasfunnels-timestamp"];
const signature = headers["x-saasfunnels-signature"] ?? "";
const age = Math.abs(Date.now() - Date.parse(timestamp));
if (!timestamp || !(age < 5 * 60 * 1000)) return false;
const expected =
"v1=" + createHmac("sha256", secret).update(`${timestamp}.${rawBody}`, "utf8").digest("hex");
return (
signature.length === expected.length &&
timingSafeEqual(Buffer.from(signature), Buffer.from(expected))
);
}In Express, read the raw body with express.raw({ type: "application/json" }) on that route. In a Next.js route handler, use await request.text().
Reply quickly and handle repeats
- Reply with any
2xxstatus within five seconds, then do the slow work afterwards. - A failed delivery is sent again with the same
x-saasfunnels-delivery-id. Store the IDs you've handled and skip repeats. - To test your check, open the endpoint's actions menu and choose Send test.
Rotate a secret
Choose Rotate signing secret from the endpoint's actions menu, then Rotate secret. The new secret is shown once, and deliveries are signed with it from then on, so update your receiver at the same time.