Skip to content
SaaSFunnelsHelp

Developers

Webhook signatures

Check that a webhook really came from SaaSFunnels before you act on it.

Where to find itSettingsIntegrationsWebhook

On this page

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

HeaderValue
x-saasfunnels-signaturev1= and a lowercase hex HMAC-SHA256
x-saasfunnels-timestampISO-8601 time the request was signed
x-saasfunnels-delivery-idA unique ID for this delivery
x-saasfunnels-eventWhat happened, such as saasfunnels.funnel.lead.v1, or saasfunnels.webhook.test for a test send

Check the signature

  1. Read the raw request body as text. Don't parse and re-serialize it first.
  2. Build the string <timestamp>.<raw body>, using the x-saasfunnels-timestamp value.
  3. Compute an HMAC-SHA256 of that string with your signing secret, as lowercase hex.
  4. Compare v1=<your result> with x-saasfunnels-signature using a constant-time comparison.
  5. Reject requests whose timestamp is more than a few minutes old.
JavaScript
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 2xx status 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.

What's next