Skip to content

Verifying requests

Webhook receivers should verify every signed request before parsing the JSON payload for business processing.

Ingrid webhook deliveries are signed with HMAC-SHA256 and include headers that allow the receiver to reconstruct and validate the signature.

Security model

Each delivery is signed with an HMAC derived from a shared secret. The request includes a creation timestamp, and receivers should verify the signature before accepting the payload.

Headers

Each delivery includes these headers:

  • X-Ingrid-Timestamp
  • X-Ingrid-Signature

X-Ingrid-Timestamp contains a Unix timestamp in UTC seconds. X-Ingrid-Signature contains the HMAC signature in the format v1=<lowercase hex digest>.

The event identifier is provided in the top-level id field in the JSON payload.

Typical request headers:

X-Ingrid-Timestamp: 1781771400
X-Ingrid-Signature: v1=5c5b0c3de9a1d1efc2d1c8e1f0c80d587f4c0f5b770d4af5e6d2d2dc7db3f6c0

Signature construction

To verify a request, read the raw HTTP request body exactly as received. Build the signed payload, meaning the exact value used as input to the HMAC calculation, as:

<X-Ingrid-Timestamp>.<raw request body>

Then compute the expected signature using your shared secret:

expected_signature = "v1=" + HEX(HMAC_SHA256(secret, signed_payload))

Compare the computed and received signatures using a constant-time comparison. Reject the request if they do not match.

Pseudo code:

timestamp = header["X-Ingrid-Timestamp"]
received_signature = header["X-Ingrid-Signature"]

signed_payload = timestamp + "." + raw_body
expected_signature = "v1=" + HEX(HMAC_SHA256(secret, signed_payload))

constant_time_compare(expected_signature, received_signature)

Read the raw request body exactly as sent, then read X-Ingrid-Timestamp and X-Ingrid-Signature. Verify that the signature format is supported, for example v1=<hex digest>, then recompute the HMAC over <X-Ingrid-Timestamp>.<raw_body> and compare the computed and received signatures using a constant-time comparison.

Only parse and process the JSON payload after signature verification succeeds. Do not pretty-print, normalize, or re-encode the request body before verification, because the signature must be computed from the exact raw bytes that were sent.

Parse the JSON payload only after signature verification succeeds, then read payload.id and use it for deduplication. Reject the request if any verification step fails.

Implementation notes

Use the raw request body bytes exactly as received. Do not parse and re-serialize JSON before verification. Treat the v1= prefix as part of the transmitted signature format.

For freshness checks and duplicate-delivery handling, refer to Replay Prevention.