Webhook Signing (HMAC-SHA256)

Overview

Signal House signs every webhook delivery with HMAC-SHA256. Signing is automatic: every webhook endpoint gets its own signing secret when it is created, and there is no setting to turn on. Your server recomputes the signature over the raw request body and rejects anything that does not match, which proves the request came from Signal House and was not altered in transit. A timestamp inside the signed string protects against replay.

Signing and Authentication Type. Every delivery from an endpoint with a signing secret is signed, whatever authType is set to. authType chooses what else Signal House sends: BASIC and API_KEY add credentials in the Authorization header as a second layer, while authType: "HMAC" (HMAC Signature in the portal) sends no credentials and states that your endpoint authenticates deliveries by the signature alone. HMAC takes no credentials or apiHeaderPrefix, and an endpoint created before signing must get a secret (below) before it can switch to it.

Signature Headers

The signature is the lowercase hex HMAC-SHA256 of the string {timestamp}.{rawBody}, keyed with the endpoint's signing secret, where timestamp is the value of X-SignalHouse-Timestamp and rawBody is the exact request body. There is no prefix on the signature.

HeaderValue
X-SignalHouse-TimestampUnix time in milliseconds (not seconds) when the delivery was signed. Each retry is signed afresh with a new timestamp.
X-SignalHouse-SignatureHex HMAC-SHA256 of {timestamp}.{rawBody}. During a rotation grace window it is computed with the previous secret, and switches to the new secret when the window ends, so a verifier that reads only this header keeps working until then.
X-SignalHouse-Signature-V1t=<ms>,v1=<hex>[,v1=<hex>]: the timestamp plus one signature per currently valid secret, newest first. During a rotation grace window it carries a signature for both the new and the previous secret; accept a match on any of them. Recommended for new verifiers.
X-SignalHouse-Delivery-IdA stable id for this event to this endpoint, reused across retries. Sent on every delivery, signed or not. Use it to deduplicate.
Example headers
X-SignalHouse-Timestamp: 1767225600000
X-SignalHouse-Signature: 5d41402abc4b2a76b9719d911017c592...
X-SignalHouse-Signature-V1: t=1767225600000,v1=5d41402abc4b2a76b9719d911017c592...
X-SignalHouse-Delivery-Id: 3f2b8c1e-6a4d-4e0f-9b7a-2c1d5e8f9a0b

Verify with the JavaScript SDK

The JavaScript SDK ships a Node.js verifier, verifyWebhookSignature, on the @signalhouse-sms/sdk/webhooks subpath. It reads X-SignalHouse-Signature-V1 and falls back to the legacy header pair, compares in constant time, and rejects timestamps more than 5 minutes old (override with toleranceMs). It never throws: it returns { valid: true } or { valid: false, reason }. Pass secrets: [newSecret, oldSecret] instead of secret while you switch over after a rotation.

Node.js (Express)
import express from "express";
import { verifyWebhookSignature } from "@signalhouse-sms/sdk/webhooks";

const app = express();

// Use express.raw so the body is the exact bytes Signal House signed.
// Parsing to JSON and re-serializing changes the bytes and breaks the signature.
app.post("/webhooks/signalhouse", express.raw({ type: "application/json" }), (req, res) => {
  const { valid, reason } = verifyWebhookSignature({
    rawBody: req.body,                               // Buffer
    headers: req.headers,
    secret: process.env.SIGNALHOUSE_WEBHOOK_SECRET,
  });
  if (!valid) return res.status(401).send(reason);

  const event = JSON.parse(req.body.toString("utf8"));
  res.sendStatus(200);                               // acknowledge within 3 seconds, then process
  // ...handle event, deduplicating on req.headers["x-signalhouse-delivery-id"]
});
reasonMeaning
no_secretNo secret was passed to the verifier.
no_signatureThe request carried no signature headers. Reject it if this endpoint has a signing secret; otherwise a forger can simply omit the headers.
bad_timestampThe timestamp header is missing or not a number.
stale_timestampThe timestamp is outside the tolerance window (5 minutes by default).
bad_signatureNo signature matched any of the secrets provided.

Verify Without the SDK

The other SDKs do not include a verifier yet. Verification takes a few lines in any language:

  1. Read the raw request body, byte for byte, before any JSON parsing.
  2. Read the timestamp and signatures. From X-SignalHouse-Signature-V1, split on ,: the t= part is the timestamp and every v1= part is a candidate signature. Otherwise use X-SignalHouse-Timestamp and X-SignalHouse-Signature.
  3. Reject the request if the timestamp is more than 5 minutes from your clock. It is in milliseconds.
  4. Compute HMAC-SHA256(secret, timestamp + "." + rawBody) as lowercase hex.
  5. Accept only if it equals one of the candidate signatures, using a constant-time comparison.
Python
import hmac, hashlib, time

def verify_signalhouse(raw_body: bytes, headers: dict, secret: str, tolerance_ms: int = 300_000) -> bool:
    h = {k.lower(): v for k, v in headers.items()}
    parts = [p.strip().split("=", 1) for p in h.get("x-signalhouse-signature-v1", "").split(",") if "=" in p]
    timestamp = next((v for k, v in parts if k == "t"), None)
    candidates = [v for k, v in parts if k == "v1" and v]
    if not candidates:  # no usable V1 header: fall back to the original pair
        timestamp = h.get("x-signalhouse-timestamp")
        candidates = [h["x-signalhouse-signature"]] if h.get("x-signalhouse-signature") else []
    if not candidates or not timestamp or not timestamp.isdigit():
        return False
    if abs(time.time() * 1000 - int(timestamp)) > tolerance_ms:
        return False
    expected = hmac.new(secret.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return any(hmac.compare_digest(expected, c) for c in candidates)

Getting and Rotating the Secret

The signing secret is a 64-character hex string, returned in plaintext exactly once: as signingSecret in the POST /webhook response, or in the POST /webhook/:id/rotate-secret response. In the portal it is shown once in a dialog after you create the webhook. Store it on your server then; no later read returns it, and responses only report hasSigningSecret.

If the secret is lost or exposed, rotate it: in the portal, open Developers → Webhooks, edit the webhook, and use Rotate signing secret in the Signing secret (HMAC-SHA256) section, or call POST /webhook/:id/rotate-secret (see Webhooks). The previous secret stays valid for a grace window so you can switch your server over without dropping deliveries: 24 hours by default, up to 7 days, or 0 to stop it immediately (graceSeconds). Until the window ends, previousSecretExpiresAt reports when. Only one previous secret is kept, so rotating again during a grace window retires the older one immediately.

Webhooks Created Before Signing

Webhook endpoints created before signing was introduced have no secret, and their deliveries are sent unsigned (no signature headers). They report hasSigningSecret: false, and the portal marks them Unsigned on the Webhooks list and in the edit view.

  1. Create a secret: in the portal, edit the webhook and click Create signing secret, or call POST /webhook/:id/rotate-secret once.
  2. Copy the secret from the dialog (or the response). It is shown once.
  3. Deploy signature verification on your server. Deliveries are signed from this point on.
Per-number inbound URLs are never signed. A phone number's primaryInboundWebhookUrl and secondaryInboundWebhookUrl have no endpoint record to hold a secret, so those deliveries carry no signature (they do carry X-SignalHouse-Delivery-Id). To verify inbound messages, subscribe a webhook endpoint to MESSAGE_RECEIVED instead.
RCS status callbacks are signed with your oldest Global webhook's secret. A statusCallbackUrl has no endpoint record of its own, so an RCS event posted to it carries the signature headers of your group's oldest Global webhook, and rotating that webhook's secret works as described above. Deleting that webhook moves signing to the next oldest. If your group has no Global webhook, or that webhook has no signing secret, the post is unsigned, so create one before you rely on verifying callbacks.
SMS, MMS and P2P status callbacks are not signed. That includes the SMS or MMS status posts of an RCS fallback leg (SENT, DELIVERED, FAILED). The MESSAGE_FALLBACK_DELIVERED event an RCS message posts to the same URL is signed. To verify delivery of SMS and MMS, subscribe a webhook endpoint instead.