Verify webhook signatures
X-Tabla-Signature is HMAC-SHA256 over the timestamp and raw body. Verify the exact bytes and compare in constant time, in Node, Python or PHP.
Updated November 2026
A webhook URL is an ordinary URL. Anything that learns it can POST to it, and without a check, your endpoint can't tell a forged request from a delivery Tabla sent. The check takes six lines. Tabla signs every delivery with a secret that only you and Tabla hold, and you recompute the signature before trusting the body.
If your endpoint only feeds a dashboard, you can skip this. As soon as it ships goods, sends email or moves money, you should verify.
What arrives
Every delivery carries three headers. These are from one we captured:
Content-Type: application/json
X-Tabla-Delivery: dlv_k6d7adu95w49.1
X-Tabla-Timestamp: 1786316454
X-Tabla-Signature: sha256=eea59eaf4e84427522e92012eb450d26e89f903b77704bb78e4a5573f9437f5c
X-Tabla-Delivery: the delivery's id and the attempt number, joined by a dot.dlv_k6d7adu95w49.1is attempt 1, and a retry of the same delivery would say.2.X-Tabla-Timestamp: when this attempt was signed, in Unix seconds.X-Tabla-Signature:sha256=followed by the hex-encoded HMAC-SHA256 overtimestamp + "." + body, keyed with the webhook's signing secret. Because the timestamp is inside the MAC, a captured request expires. Replaying it later means replaying its old timestamp, and your freshness check refuses that.
Every attempt is signed when it's sent. A retry or a replay carries a fresh timestamp and a fresh signature, so your check works the same way for all of them.
The secret is on the webhook's page, under Signing secret. Editors and owners can see it, and viewers never can. Each webhook gets its own secret, so a secret that leaks from one receiver can't sign deliveries for any other webhook.
The two rules
- Verify the raw body, meaning the exact bytes received, before any JSON parser touches them. Parsing and then re-stringifying can reorder keys or change whitespace, and then a valid delivery fails your check.
- Compare in constant time. A plain
===leaks, byte by byte, how much of the signature an attacker got right. Every language below has a constant-time compare, so use it.
Node
const { createHmac, timingSafeEqual } = require("node:crypto");
// rawBody: string or Buffer of the EXACT request body.
function verifyTablaSignature(rawBody, timestamp, signatureHeader, secret) {
const age = Math.abs(Math.floor(Date.now() / 1000) - Number(timestamp));
if (!Number.isFinite(age) || age > 300) return false; // older than 5 minutes
const expected =
"sha256=" +
createHmac("sha256", secret).update(`${timestamp}.${rawBody}`).digest("hex");
const a = Buffer.from(expected);
const b = Buffer.from(signatureHeader);
return a.length === b.length && timingSafeEqual(a, b);
}
In Express, mount the route with express.raw({ type: "application/json" })
so req.body is the untouched Buffer, then:
app.post("/hook", express.raw({ type: "application/json" }), (req, res) => {
const ok = verifyTablaSignature(
req.body,
req.get("x-tabla-timestamp"),
req.get("x-tabla-signature"),
process.env.TABLA_WEBHOOK_SECRET,
);
if (!ok) return res.status(401).end();
const delivery = JSON.parse(req.body); // parse only after verifying
res.status(200).end(); // acknowledge fast, work after
});
We ran this function, as written, against thirteen deliveries captured from Tabla. All thirteen verified, and flipping a single byte in the body made the check fail, as it should.
Python
import hmac, hashlib, time
def verify_tabla_signature(raw_body: bytes, timestamp: str, signature_header: str, secret: str) -> bool:
if abs(time.time() - int(timestamp)) > 300:
return False
mac = hmac.new(secret.encode(), f"{timestamp}.".encode() + raw_body, hashlib.sha256)
expected = "sha256=" + mac.hexdigest()
return hmac.compare_digest(expected, signature_header)
In Flask, the raw bytes are request.get_data(), and in Django they're
request.body.
PHP
function verify_tabla_signature(string $rawBody, string $timestamp, string $signatureHeader, string $secret): bool {
if (abs(time() - (int)$timestamp) > 300) return false;
$expected = 'sha256=' . hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
return hash_equals($expected, $signatureHeader);
}
// $rawBody = file_get_contents('php://input');
We ran the Python and PHP functions against the same captured deliveries. Every untouched delivery verified, and every tampered body failed.
Rotating the secret
If the secret leaks (it ended up in a log, say, or a laptop went missing), regenerate it with Signing secret → Regenerate… on the webhook's page, or over the API:
curl -X POST https://tabladb.com/api/webhooks/whk_wn6xcsbfk3by/secret \
-H "Authorization: Bearer key_xxxx.your-secret"
Rotation takes effect at once. The old secret stops verifying the moment the new one exists, and there is no overlap window where both sign. Deliveries attempted after the rotation (including retries of earlier failures) are signed with the new secret. Put the new secret on your receiver straight away, expect a brief window of 401s from your own verifier, then replay anything that failed during the swap.
Choosing the freshness window
Tabla always sends the timestamp, and you choose how old is too old. Five
minutes (the 300 above) comfortably covers clock drift and retries. With a
window in place, a captured request can't be re-sent to your endpoint next
week, because its timestamp is bound into the MAC and no longer passes.
For what's inside the body once you trust it, see webhook payloads.