FMFlowMatrix
Engineeringwebhooksreliabilityintegrationevents

Webhook Reliability: Idempotency, Retries and Dead-Letter Queues

Most integration bugs are not logic errors. They are duplicate events, lost retries and silent failures. Here is how to design webhooks that survive real traffic.

Source: Stripe Engineering Blog

The failure mode nobody plans for

A webhook endpoint that works in staging usually fails in production for three reasons: the same event arrives twice, a downstream service is briefly unavailable, or an event is delivered but never processed. None of these are exotic. They are the normal behaviour of distributed systems, and they need to be designed for explicitly.

Assume every event can arrive twice

At-least-once delivery is the default for most providers. Your handler must therefore be idempotent. The simplest approach is to store the provider's event ID and reject duplicates before doing any work. If the provider does not send a stable ID, derive one from the event type and payload hash.

Idempotency should cover side effects, not just database writes. Sending an email, charging a card or creating a ticket are all operations that must not happen twice for the same event.

Retry with backoff, then stop

Retries are essential, but unbounded retries are a denial-of-service attack you inflict on yourself. Use exponential backoff with jitter, cap the number of attempts, and make the retry window explicit. After the window closes, move the event to a dead-letter queue instead of dropping it silently.

A dead-letter queue is not a graveyard. It is an operational surface: someone must be able to inspect failed events, fix the cause and replay them safely.

Make failures observable

Log the event ID, the attempt number, the response status and the time spent. Emit metrics for delivery latency, failure rate and queue depth. Alert on sustained failures, not on single errors. Without this, a broken integration can go unnoticed for days while events pile up.

Verify signatures and validate payloads

Always verify the provider's signature before processing an event. Validate the payload against a schema and reject malformed events early. This protects both your system and your downstream services from garbage data.

A practical checklist

Store event IDs, make handlers idempotent, retry with backoff, cap attempts, use a dead-letter queue, verify signatures, validate payloads and monitor queue depth. None of these steps is complicated on its own; together they turn a fragile endpoint into a reliable integration.

The Webhook Event Routing workflow walks through the routing, retry and dead-letter setup in detail.

Reliability is not about preventing failures. It is about making them visible, bounded and recoverable.

Based on reporting fromStripe Engineering Blog. This article is an independent analysis and does not reproduce the original content.