I built a handler that listened to a webhook, parsed the payload, and created a record. During testing I retried a delivery manually and got a duplicate. Fine, I thought β I'll just dedupe on the event ID. Then a real retry happened 40 minutes later with a slightly different timestamp and my dedup silently missed it. The record was created twice and downstream billing picked up both.
The mistake was treating idempotency as a client-side courtesy. What actually matters is the key: a stable identifier the sender puts in an Idempotency-Key header, and the receiver stores against the resulting side effect. If the key is present and already seen, return the original response, do not re-execute. If it's missing, you have to either generate one from deterministic inputs or refuse the request.β¦