Verifying webhook signatures

Every webhook Quillstack sends includes a signature header. Verify it before you trust the payload, so that an attacker cannot send fake events to your endpoint.

How signing works

Quillstack signs the raw request body with HMAC-SHA256, using your endpoint's signing secret as the key. The result is sent in the Quillstack-Signature header, together with a Unix timestamp.

The header looks like this:

Quillstack-Signature: t=1767225600,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd

Verify a signature

  1. Read the raw request body as bytes, before any JSON parsing.
  2. Split the header on commas and read the t and v1 values.
  3. Build the signed string by joining the timestamp, a full stop, and the raw body.
  4. Compute HMAC-SHA256 of that string with your signing secret and compare it to v1 using a constant-time comparison.
import hmac, hashlib

def verify(raw_body: bytes, header: str, secret: str) -> bool:
    parts = dict(item.split("=", 1) for item in header.split(","))
    signed = parts["t"].encode() + b"." + raw_body
    expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])

Note: Reject any event whose timestamp is more than 300 seconds old. This blocks replay attacks even if a signed payload leaks.

Signing secret rotation

You can rotate a secret from the dashboard at any time. During rotation both the old and new secrets stay valid for 24 hours, and Quillstack sends one v1 value for each.

Header valueMeaningRequired
tUnix timestamp when the event was signedYes
v1HMAC-SHA256 signature, hex encodedYes
v0Legacy SHA1 signature, sent only to endpoints created before 2024No