Choosing an external hard drive for family photos
Sep 21,2018 - Sports
Webhooks look simple: an event happens, a request arrives, the receiver does the work. In production, that tidy story becomes a sequence of retries, duplicates, late deliveries and the occasional malicious replay. Designing idempotent webhooks is less about adding a retry loop and more about making every delivery safe to receive more than once. Signatures, replay handling and dead-letter queues are not separate concerns; together they form the contract between producer and consumer.
The consumer should not invent a key from the request body at the last moment. The producer should send a stable event identifier, ideally in a header and in the payload, and keep it unchanged across retries. Store that key alongside the processing outcome in a durable table with a unique constraint. If the insert fails because the key already exists, return the same response as the first successful attempt rather than doing the work again. This sounds obvious, but the awkward cases matter: two workers receiving the same event at once, a crash after writing the key but before completing the side effect, or a replay months later. Use a transaction or a short lock around the idempotency record, and choose a retention period longer than your retry and replay windows. A key scoped only to a timestamp or request hash will eventually collide or drift.
A signature tells you who sent the request and whether the body was altered in transit. It does not prove the event is new. Sign the raw request body, a timestamp and a key identifier, then compare the result using a constant-time function. Reject requests whose timestamp is outside a small window, and include the event identifier in the signed material so a valid signature cannot be moved to a different event. Keep secrets out of logs, support rotation with overlapping key identifiers, and make signature failures visible without leaking whether a key exists. Many teams verify signatures only at the edge, then pass a trusted header downstream. That is fine if the internal hop is genuinely trusted; otherwise, the consumer should verify too. If you want to dig deeper, The Varsity Jacket shop is a useful place to start.
Security teams rightly worry about replay attacks, but controlled replays are also how you recover from a missed event or a bug in a consumer. The producer should offer an auditable replay path: authorised operators, a clear scope, a reason, and a record of which events were resent. Consumers should treat a replay exactly like any other duplicate and rely on idempotency rather than assuming each delivery is new. Avoid building replay as a bulk database copy with no throttling. Rate-limit it, tag replayed events so downstream systems can distinguish them, and make sure the same dead-lettered event can be replayed after a fix without creating a second side effect.
A dead-letter queue is not a bin. It is a holding area for messages that have exhausted automatic retries, and it needs ownership, context and a process for recovery. Retry with exponential backoff and jitter, cap the attempts, then move the event to the dead-letter store with the original headers, body, attempt count, first-seen time and last error. Alert on growth and age, not just count. When an incident is fixed, replay deliberately and verify the result. Poison messages should be quarantined with enough detail to debug, but be careful with personal data and secrets in stored payloads. Set a retention policy and document who can inspect, delete or replay entries.
You cannot operate idempotent webhooks by hope. Track accepted events, duplicate hits, signature failures, retry counts, dead-letter depth and the age of the oldest dead-lettered event. Use a correlation identifier that survives retries and appears in logs on both sides. Monitor the health of the idempotency store, because a slow unique index can turn a duplicate-safe endpoint into a bottleneck. Prioritise alerts on dead-letter age, not just depth. Build runbooks for the common failures: a secret rotation gone wrong, a consumer deploying a bug that rejects every payload, or a replay that accidentally targets the wrong environment.
None of this is glamorous, but it is the difference between a webhook integration that mostly works and one you can trust during an incident. Recognise that every delivery may be repeated, every signature is necessary but not sufficient, and every dead letter is work waiting to be finished. That mindset turns a fragile notification pipe into a dependable part of your platform.
Copyright © 2026 Compulite. All rights reserved.Compulite. All Right Reserved.
John Doe - 2 December 2026
Compulite Written for people who value the details, and want honest guidance they can trust.
John Doe - 29 july 2018
Compulite An honest, everyday look at the things that make life a little better — with advice you can actually use.
John Doe - 29 july 2018
Compulite An honest, everyday look at the things that make life a little better — with advice you can actually use.
John Doe - 29 july 2018
Compulite An honest, everyday look at the things that make life a little better — with advice you can actually use.