{"templateId":"markdown","versions":[{"version":"v1","label":"v1","link":"/developer-resources/ingrid-api/v1/webhooks/verifying-requests","default":true,"active":false,"folderId":"570314d1"},{"version":"v1.preview","label":"v1.preview","link":"/developer-resources/ingrid-api/v1.preview/webhooks/verifying-requests","default":false,"active":true,"folderId":"570314d1"}],"sharedDataIds":{"sidebar":"sidebar-developer-resources/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Verifying requests"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"verifying-requests","__idx":0},"children":["Verifying requests"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Webhook receivers should verify every signed request before parsing the JSON"," ","payload for business processing."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ingrid webhook deliveries are signed with HMAC-SHA256 and include headers that"," ","allow the receiver to reconstruct and validate the signature."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"security-model","__idx":1},"children":["Security model"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"headers","__idx":2},"children":["Headers"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Each delivery includes these headers:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Ingrid-Timestamp"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Ingrid-Signature"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Ingrid-Timestamp"]}," contains a Unix timestamp in UTC seconds. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Ingrid-Signature"]}," ","contains the HMAC signature in the format ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1=<lowercase hex digest>"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The event identifier is provided in the top-level ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," field in the JSON"," ","payload."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Typical request headers:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"text","header":{"controls":{"copy":{}}},"source":"X-Ingrid-Timestamp: 1781771400\nX-Ingrid-Signature: v1=5c5b0c3de9a1d1efc2d1c8e1f0c80d587f4c0f5b770d4af5e6d2d2dc7db3f6c0\n","lang":"text"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"signature-construction","__idx":3},"children":["Signature construction"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"text","header":{"controls":{"copy":{}}},"source":"<X-Ingrid-Timestamp>.<raw request body>\n","lang":"text"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Then compute the expected signature using your shared secret:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"text","header":{"controls":{"copy":{}}},"source":"expected_signature = \"v1=\" + HEX(HMAC_SHA256(secret, signed_payload))\n","lang":"text"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Compare the computed and received signatures using a constant-time comparison."," ","Reject the request if they do not match."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pseudo code:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"text","header":{"controls":{"copy":{}}},"source":"timestamp = header[\"X-Ingrid-Timestamp\"]\nreceived_signature = header[\"X-Ingrid-Signature\"]\n\nsigned_payload = timestamp + \".\" + raw_body\nexpected_signature = \"v1=\" + HEX(HMAC_SHA256(secret, signed_payload))\n\nconstant_time_compare(expected_signature, received_signature)\n","lang":"text"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"recommended-verification-flow","__idx":4},"children":["Recommended verification flow"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Read the raw request body exactly as sent, then read ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Ingrid-Timestamp"]}," and"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["X-Ingrid-Signature"]},". Verify that the signature format is supported, for"," ","example ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1=<hex digest>"]},", then recompute the HMAC over"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<X-Ingrid-Timestamp>.<raw_body>"]}," and compare the computed and received"," ","signatures using a constant-time comparison."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["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."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Parse the JSON payload only after signature verification succeeds, then read"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payload.id"]}," and use it for deduplication. Reject the request if any"," ","verification step fails."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"implementation-notes","__idx":5},"children":["Implementation notes"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the raw request body bytes exactly as received. Do not parse and"," ","re-serialize JSON before verification. Treat the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["v1="]}," prefix as part of the"," ","transmitted signature format."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For freshness checks and duplicate-delivery handling, refer to"," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/developer-resources/ingrid-api/v1.preview/webhooks/replay-prevention"},"children":["Replay Prevention"]},"."]}]},"headings":[{"value":"Verifying requests","id":"verifying-requests","depth":1},{"value":"Security model","id":"security-model","depth":2},{"value":"Headers","id":"headers","depth":2},{"value":"Signature construction","id":"signature-construction","depth":2},{"value":"Recommended verification flow","id":"recommended-verification-flow","depth":2},{"value":"Implementation notes","id":"implementation-notes","depth":2}],"frontmatter":{"title":"Verifying Requests","description":"How to verify signed Ingrid webhook requests with HMAC-SHA256","seo":{"title":"Verifying requests"}},"lastModified":"2026-09-16T11:59:37.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/developer-resources/ingrid-api/v1.preview/webhooks/verifying-requests","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}