Skip to content

How to build a webhook consumer

Verify the signature, deduplicate by event ID, respond fast (2xx in <5s), process async, and monitor failures.

Consuming a webhook safely

  1. Verify the signature

    Use HMAC-SHA256 with a shared secret and the raw body. Reject anything that does not match.

  2. Deduplicate by event ID

    Webhooks deliver at least once. Store processed event IDs and ignore duplicates.

  3. Respond fast

    Return 2xx within 5 seconds. Push the payload onto a queue and process it in the background.

  4. Make the endpoint idempotent

    Two deliveries of the same event must not create two orders.

  5. Monitor and retry

    Log every webhook. Alert on failures. Let the sender retry; if it doesn't, retry yourself.