Skip to main content

Every webhook Capa sends is signed with your webhook secret, so you can confirm that it comes from Capa and was not modified. Each delivery carries two signatures: Both are HMAC-SHA256, hex-encoded (lowercase), keyed with your webhook secret. We recommend verifying capa-signature-v2: it also binds the timestamp and delivery id, so you can reject old or replayed deliveries.
Compute the signature over the raw request body bytes exactly as received. Do not parse the JSON and re-serialize it (for example with JSON.stringify(req.body)): that can change key order, spacing or number formatting, and the signature will not match.

Step 1: Keep the Raw Body

Configure your framework to give you the unparsed body for the webhook route. For example, in Express:

Step 2: Compute the Expected Signature

  • Key: your webhook secret, used as-is as a UTF-8 string. It looks like a hex string, but do not hex-decode it.
  • Message (v2): the capa-timestamp header, a ., the capa-delivery-id header, a ., then the raw body.
  • Message (v1): the raw body alone.

Step 3: Compare in Constant Time

In Python, use hmac.compare_digest(expected, received). capa-timestamp is the Unix time in seconds of the delivery attempt and is regenerated on every retry. With capa-signature-v2 you can reject a delivery whose timestamp is too far from your current time (for example more than 5 minutes) to protect against replays. Keep your server clock in sync if you do.

Step 5: Process the Event

  • If the signature does not match, reject the request (for example with 401) and do not process it.
  • If it matches, deduplicate on capa-delivery-id (the same notification can be delivered more than once), then answer with a 2xx status. See Delivery Semantics.

What’s Next