Verify the signature, deduplicate by event ID, respond fast (2xx in <5s), process async, and monitor failures.
Consuming a webhook safely
Verify the signature
Use HMAC-SHA256 with a shared secret and the raw body. Reject anything that does not match.
Deduplicate by event ID
Webhooks deliver at least once. Store processed event IDs and ignore duplicates.
Respond fast
Return 2xx within 5 seconds. Push the payload onto a queue and process it in the background.
Make the endpoint idempotent
Two deliveries of the same event must not create two orders.
Monitor and retry
Log every webhook. Alert on failures. Let the sender retry; if it doesn't, retry yourself.