Verify webhook signatures
Anyone who knows your endpoint's address could send it a request. Every Syott delivery is signed with your webhook's secret, so you can check it really came from Syott and wasn't changed on the way. This page is for developers. It explains the signature scheme and gives a working example.
How deliveries are signed
Syott computes an HMAC-SHA256 over the timestamp and the raw request body, joined with a dot:
signed_payload = X-Syott-Timestamp + "." + raw_body
signature = "sha256=" + hex(HMAC_SHA256(signing_secret, signed_payload))
It sends the result in X-Syott-Signature, with the timestamp in X-Syott-Timestamp (Unix seconds) and the algorithm in X-Syott-Algorithm (sha256).
Verify a delivery
- Read the raw request body, exactly as received. Don't parse and re-serialise the JSON first: any change, even to spacing or key order, changes the signature.
- Read
X-Syott-TimestampandX-Syott-Signature. - Check the timestamp is within 5 minutes of your server's clock. Reject the request if it isn't; this stops an old delivery from being replayed against you.
- Compute
sha256=+ the hex HMAC-SHA256 oftimestamp + "." + raw_bodywith your signing secret. - Compare your result with
X-Syott-Signatureusing a constant-time comparison. If they match, the delivery is genuine.
Node.js
import crypto from 'node:crypto';
function verifySyottWebhook(rawBody, headers, secret) {
const timestamp = headers['x-syott-timestamp'];
const received = headers['x-syott-signature'] ?? '';
const prior = headers['x-syott-signature-prior'];
const age = Math.abs(Date.now() / 1000 - Number(timestamp));
if (!Number.isFinite(age) || age > 300) return false;
const expected =
'sha256=' + crypto.createHmac('sha256', secret).update(`${timestamp}.${rawBody}`).digest('hex');
const matches = (sig) =>
typeof sig === 'string' &&
sig.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
return matches(received) || matches(prior);
}Pass the body as the exact string or buffer you received. In Express, for example, use express.raw({ type: 'application/json' }) on your webhook route.
Python
import hashlib
import hmac
import time
def verify_syott_webhook(raw_body: bytes, headers, secret: str) -> bool:
timestamp = headers.get("X-Syott-Timestamp", "")
if not timestamp.isdigit() or abs(time.time() - int(timestamp)) > 300:
return False
mac = hmac.new(secret.encode(), timestamp.encode() + b"." + raw_body, hashlib.sha256)
expected = "sha256=" + mac.hexdigest()
candidates = [headers.get("X-Syott-Signature"), headers.get("X-Syott-Signature-Prior")]
return any(sig and hmac.compare_digest(sig, expected) for sig in candidates)While you rotate the secret
For 24 hours after you rotate a webhook's signing secret, each delivery carries two signatures: X-Syott-Signature made with the new secret and X-Syott-Signature-Prior made with the old one. Both examples above accept either.
To rotate without missing a delivery:
- Rotate the secret in the admin centre and copy the new one.
- Update your system to the new secret within 24 hours.
If your system checks both headers, as the examples do, it keeps verifying deliveries during that window, whichever of the two secrets it holds.
Also check
- Process each delivery once. Retries reuse the same
Idempotency-Key(the delivery ID). Record the keys you've handled and skip repeats. - Use HTTPS. Syott only delivers to HTTPS endpoints, so the body and secret-derived signature aren't exposed in transit.