Every webhook delivery carries an X-Baas-Signature header:
This is an HMAC-SHA256 of the exact raw request body bytes, keyed with
the signing secret you received from
Configure Your Webhook.
Compute the HMAC over the raw bytes of the request body, before your
framework parses it into an object — re-serializing a parsed JSON object
can reorder keys or change whitespace, which changes the bytes and makes
the signature look wrong even though the request is genuine. Read the raw
body first, verify, then parse it.
Verify it
Always use a constant-time comparison (crypto.timingSafeEqual,
hash_equals) — never ===/== — so an attacker can’t guess your secret
byte-by-byte via response-timing differences.
What to do after verifying
- Check
event (X-Baas-Event header, or the event field in the body)
against the events you actually handle — see Webhook Events.
- Respond
2xx quickly (Rex doesn’t wait long) — do slow work
(database writes, side effects) after responding, or in a background job.
- Treat delivery as at-most-once — see
Retries. If you need a stronger guarantee,
reconcile periodically against
List Transactions
rather than relying on webhooks alone.