Post-Incident Recovery, Replay & State Reconciliation: A Complete Engineering Guide
Master post-incident webhook recovery. Compare selective vs. full replay, filter permanent 4xx errors, reconcile missed events with APIs, and verify state convergence.

Post-Incident Recovery, Replay & State Reconciliation: A Complete Engineering Guide
When an external API integration or internal consumer service suffers an outage, getting the HTTP endpoint back to a 200 OK state is only half the battle. In event-driven architectures built on webhooks, downtime creates an invisible consistency gap. Events generated during the outage may have failed delivery, exhausted their automatic retry schedules, or been acknowledged by an ingestion layer before a downstream worker crashed.
Blindly hitting “replay all” on a dead letter queue (DLQ) after an incident can turn a minor availability blip into a data-corruption event. Duplicate invoices, double-shipped orders, out-of-order state regressions, and thundering herd overloads frequently follow poorly planned recovery runs.
This guide gives you a framework for post-incident webhook recovery. It covers how to pick a replay strategy, how to reconcile missed events against source-of-truth APIs, how to design a retry classifier, and how to show with auditable evidence that downstream state has converged without duplicate side effects. Provider behavior described here was checked against official documentation as of November 2026. Retry windows change, so confirm the numbers for your providers before building runbooks around them.
1. Selective Replay vs. Full Re-Drive: Choosing the Right Recovery Strategy After an Outage
When a webhook destination recovers after hours of downtime, you typically face a backlog of stalled events. They may sit in a provider’s retry queue, an event gateway such as Hookdeck or Svix, an AWS EventBridge target DLQ, or your own internal queue. The right recovery strategy depends on the blast radius, the payload volume, and how stateful the events are.
Defining the Incident Boundary First
Before triggering any redelivery mechanism, establish a strict incident boundary:
- The last known good checkpoint. Identify the exact timestamp or event ID (for example a Stripe
evt_...ID or thewebhook-idheader) that completed end-to-end processing before the outage. - The failure mode. Determine whether events failed at the network edge and never reached your ingress, failed signature or schema verification, were persisted to a queue without worker execution, or returned
200 OKwhile silently dropping mutations. Each mode needs a different fix. - The overlap buffer. Add a safety margin before the detected failure (for example 15 to 30 minutes) to capture in-flight requests that timed out mid-transaction. Idempotency (Section 4) is what makes an overlap safe.
Comparing Recovery Strategies
| Recovery strategy | Best used when | Throughput and risk profile | Key operational guardrail |
|---|---|---|---|
| Single-event replay | Debugging a specific payload, validating a hotfix in production, or fixing a bug that affected isolated records. | Lowest risk, lowest throughput. | Verify idempotency and inspect the resulting database mutations. |
| Filtered bulk replay | Specific event types, tenants, or failure statuses failed during a bounded time window. | Moderate risk, high throughput. Can trigger rate limits (429) or lock contention if unthrottled. | Filter by event type, time window, and failure status; throttle delivery; ramp up gradually. |
| Full re-drive (DLQ flush) | A complete consumer outage where every event in a dedicated queue failed before business logic ran. | Highest risk, maximum throughput. Likely to cause load spikes and out-of-order execution. | Strict idempotency, concurrency caps, and stale-event protection on every write. |
| Targeted catch-up job | The outage exceeded the sender’s retry or redelivery window, or event ordering is too tangled to replay safely. | Low risk, controlled throughput. Bypasses stale event queues in favor of current entity state. | Query source-of-truth APIs directly and apply state diffs rather than replaying historical transitions. |
When to Choose Filtered Bulk Replay Over Full Re-Drive
A full re-drive drains every message from a DLQ or failed-delivery log indiscriminately. Many native tools work this way. For example, Amazon SQS’s DLQ redrive moves messages back to the source queue (or a custom destination) oldest first, and it does not support filtering or modifying messages while redriving. A full re-drive is dangerous when:
- Mixed failure types coexist. Your DLQ holds transient
503errors from last night’s outage alongside payloads that were rejected with400weeks ago and will fail again. - High-frequency state churn occurred. A single subscription or order generated many sequential updates (
created→updated→paused→canceled) during the outage. Replaying every event wastes compute and invites race conditions if workers process them concurrently.
Filtered bulk replay narrows the recovery set using event metadata. Gateways and providers expose this in different ways:
- Hookdeck lets you filter the event list (by status, time range, and so on) and bulk-retry only the matches. It warns that bulk retries are queued alongside new events and can affect delivery latency.
- Svix lets you manually retry a single message, “recover” all failed messages to an endpoint from a given date, or replay messages that were never attempted.
- Stripe lets you list events with
delivery_success=falseand filter by event type, then resend individually from the Dashboard or CLI.
A typical filter might be: delivery failed, created_at between incident_start - buffer and incident_end, and event type in the specific set your handlers care about (for example invoice.paid and checkout.session.completed).
Execution Rules for Safe Bulk Replays
- Replay oldest first, but don’t rely on it. Sort replay batches ascending by the event’s original creation time, not by the time of its last failed attempt. Treat this as best effort. Stripe states that it doesn’t guarantee delivery order, and Shopify makes no ordering guarantee either. Your handlers must tolerate out-of-order arrival (see Section 4).
- Throttle, and protect live traffic. Dumping tens of thousands of queued events onto a freshly restarted service will trigger
503s and429s, and the replay will compete with real-time events. Use the rate controls your tooling provides. SQS redrive supports a custom maximum velocity (up to 500 messages per second) and recommends starting low and ramping up while watching the destination. Hookdeck destinations support a configurable maximum delivery rate or concurrency limit. Increase the rate gradually as p95 latency and error rates stay healthy. - Handle signature timestamp tolerance deliberately. The Standard Webhooks specification tells receivers to verify that
webhook-timestampis within an allowable tolerance of the current time to prevent replay attacks. The spec doesn’t fix the window; its reference libraries default to five minutes. The timestamp represents the delivery attempt, so a provider-initiated retry or manual replay gets a fresh timestamp and a fresh signature, and passes verification normally. The problem arises only when you re-feed stored payloads to your own handler. Don’t weaken verification in the public handler for this. Verify the signature and timestamp once at ingress, persist the verified payload, and replay it through an internal, authenticated path that skips the provider-signature check. - Expect providers to keep retrying what you processed manually. Stripe notes that events you process manually through the API are still considered undelivered and continue on the automatic retry schedule. A recovery run followed by a late automatic retry is a duplicate unless your consumer is idempotent.
2. Reconciling Missed Webhooks with Source-of-Truth APIs After Extended Downtime
Even the most resilient webhook systems have finite retry and retention windows, and they differ widely by provider:
| Provider | Automatic retries | Manual recovery options | Notable consequences |
|---|---|---|---|
| Stripe | Live mode: exponential backoff for up to 3 days. Sandbox: 3 attempts over a few hours. | Dashboard resend up to 15 days after creation; stripe events resend up to 30 days; List Events API (delivery_success=false) returns only events from the last 30 days. | Stripe emails you in live mode when deliveries are failing. If an endpoint is disabled or deleted when a retry comes due, that event’s future retries are canceled. |
| Svix-based senders | 8 attempts (immediately, then after 5s, 5m, 30m, 2h, 5h, 10h, 10h), roughly 27.5 hours in total. | Resend one message, recover failed messages from a date, or replay never-attempted messages. | The endpoint is disabled after 5 days of failures, and an operational webhook is emitted. |
| GitHub | None. GitHub does not automatically redeliver failed deliveries. | Manual or API redelivery of deliveries from the past 3 days. | You need your own script or job to find and redeliver failures within the window. |
| Shopify | Up to 8 retries over about 4 hours. | Re-subscribe to topics if needed, then import missing data via the API. | Subscriptions can be removed after persistent failures, after which no deliveries arrive until recreated. |
| Twilio (classic webhooks) | By default one retry, and only on TCP connect or TLS handshake failure. | Configurable retry count (up to 5) and policy via URL fragment; fallback URLs; reconcile via the REST API. | A 5xx from your server does not trigger the default retry. |
| Amazon EventBridge (rule targets) | Default: up to 24 hours and 185 attempts, with exponential backoff and jitter. Configurable per target. | Configure an SQS DLQ to catch events after retries are exhausted. | Without a DLQ, an event that exhausts its retries is dropped. |
Sources are listed at the end of this article. If your outage exceeds a sender’s window, or a firewall silently dropped traffic so nothing was ever logged, the events are gone from the sender’s retry system and sometimes from your ingress logs too. Webhooks are a notification mechanism, not a durable system of record. Durable correctness means pairing webhook ingestion with periodic pull-based reconciliation against the provider’s API.
The Hybrid Push-Pull Reconciliation Architecture
Treat webhooks as the fast, low-latency primary path. Build a scheduled reconciliation sweep as the deterministic safety net.
[Source-of-Truth Provider]
│ ▲
│ 1. Push (webhooks) │ 3. Pull (events / resource listing API)
▼ │ e.g. GET /events?since=checkpoint
[Webhook Ingress] ──► [Local State DB] ◄── [Reconciliation Worker]
│ ▲
│ 2. Delivery logs │
└─────────────────────┘ (compare local records vs. remote state)
Step-by-Step Reconciliation Workflow
Step 1: Anchor the Query Window with Overlap
Never rely solely on the timestamp when your monitoring alert fired. Query the provider’s events API or resource-listing endpoint starting from your last verified checkpoint minus an overlap window.
For Stripe, anchoring on the last successfully processed event with ending_before and filtering on delivery_success=false returns events that failed delivery to at least one of your endpoints. Stripe’s docs note that this approach, with auto-pagination, returns events in chronological order:
curl -G https://api.stripe.com/v1/events \
-u "$STRIPE_SECRET_KEY:" \
-d ending_before=evt_LAST_PROCESSED_ID \
-d "types[]=payment_intent.succeeded" \
-d "types[]=charge.refunded" \
-d delivery_success=false \
-d limit=100
Two constraints apply. Stripe only returns events created in the last 30 days, and the default page size is small, so page through all results.
Step 2: Separate Event Identity from Entity Identity
A common mistake is conflating the identity of a webhook event with the identity of the business entity it describes (such as order_id or subscription_id).
- One entity can legitimately go through many state transitions during an outage, so deduplicating by
entity_idwould discard valid updates. - The event or message ID (Stripe’s event
id, or thewebhook-idheader in Standard Webhooks) stays the same across every retry of the same event. The Standard Webhooks spec describes the ID as stable across retries and suitable as an idempotency key. Dedupe on this, not on a per-attempt identifier or timestamp.
Step 3: Reconcile Current State Before Replaying Side Effects
After extended downtime (24+ hours), replaying raw historical events is often inferior to state-based reconciliation. Consider a subscription that was activated at 02:00 UTC, upgraded at 04:00, and canceled at 06:00 while your service was offline. If you replay all three events at 08:00, you might send a “Welcome to Pro!” email to a customer who has already canceled.
Instead:
- Fetch the current authoritative resource from the provider’s API (for example
GET /v1/subscriptions/{id}). - Compare it with your local record (upstream
status: canceledvs. localstatus: pending). - Update local state to match the source of truth, and evaluate business rules against the net transition (
pending→canceled) rather than every intermediate trigger. - Route ambiguous records to a manual exception queue instead of guessing. An example is a record where an invoice was created locally but the payment capture status is unknown.
This also matches provider guidance. Stripe recommends that handlers rely on an object’s current state rather than on arrival order, and that you fetch the current object when an event is ambiguous. Webhook specs describe “thin” payloads (identifiers only) as a deliberate design. Handlers using them fetch current state by design, which makes this pattern natural.
Reconciliation sweeps make many API calls. Run them with concurrency limits and respect the provider’s API rate limits, or the recovery job itself can cause a second incident.
3. When Not to Retry a Failed Webhook: Distinguishing Transient 5xxs from Permanent 4xx and Auth Errors
First, a reality check. Most major senders do not distinguish error classes the way the textbook says they should. The Standard Webhooks specification treats any non-2xx response as a failed delivery. It gives special handling for only a few codes: 3xx is a failure (don’t follow redirects), 410 Gone means the sender should disable the endpoint, 429, 502, and 504 call for throttling, and a Retry-After header should be honored when present. Stripe, Shopify, and Svix retry according to their schedules regardless of whether you returned 400, 401, or 500. Svix, for instance, does not treat a 410 specially and retries it like any other failure.
So the classifier below matters most in your own delivery and retry engine. It applies if you send webhooks to customers, forward events between internal services, or run a replay tool. Even for pure consumers, understanding it tells you what your own responses will provoke.
The HTTP Response Classification Matrix
| Status / error class | Examples | Classification | Suggested policy |
|---|---|---|---|
| Network / transport errors | Connection timeout, DNS failure, connection reset, TLS handshake timeout | Transient | Retry with exponential backoff and jitter. |
| 5xx server errors | 500, 502, 503, 504 | Transient | Retry with backoff and jitter. For 502/504, throttle the destination, since the receiver or its gateway is likely under load. Honor Retry-After on 503 if present. |
| 429 Too Many Requests | Receiver rate limit hit | Transient (throttled) | Honor Retry-After if provided and pause the destination’s queue rather than retrying on the normal short schedule. |
| 408 Request Timeout | Server timed out waiting for the request | Usually transient | Retry with backoff. Safe only if the receiver is idempotent. |
| 401 / 403 | Invalid secret, expired token, IP blocklist | Likely permanent until someone fixes configuration | Stop fast retries. Park events and alert the endpoint owner. Allow a bounded number of slow retries if rotation or deploys are in flight. |
| 404 | Route not found | Ambiguous | Often a misconfigured URL, but it can appear during deployments or routing changes. Retry a bounded number of times, then park and alert. |
| 410 Gone | Endpoint intentionally retired | Permanent (per Standard Webhooks) | Disable the endpoint and stop sending. |
| 400 / 422 | Schema validation failed, malformed payload | Permanent for the same bytes and the same receiver code | Don’t hammer. Park for replay after the receiver is fixed (see below). |
| 3xx redirects | 301, 302, 307, 308 | Failure | Don’t follow. The spec’s reasoning is that following redirects burdens both sides, so update the endpoint URL instead. |
A key nuance for incident recovery is that “permanent” is relative to the receiver’s current code. If a bad deploy caused your service to return 400 or 422 for valid payloads, those events become deliverable again once you ship the fix. The right treatment is to stop fast retries, park the events in a DLQ rather than discarding them, and replay them after the fix, using the filtered bulk replay process from Section 1.
Why Indiscriminate Retrying Is Harmful
- Wasted capacity. Retries consume worker threads and egress. In a hypothetical multi-tenant sender where 500 endpoints each have one queued event and all start returning
400after a breaking change, 8 attempts each means 4,000 calls that are very unlikely to succeed. Those calls compete with healthy deliveries for the same workers. - Amplified load on a struggling receiver. AWS’s Builders’ Library describes retries as “selfish” because each one spends more of the server’s time. It also shows how retries at several layers of a call stack multiply (three tries at each of five layers can multiply load by 243x on the final dependency).
- Masked configuration drift. If a sender keeps retrying an endpoint with a revoked credential, nobody notices until deliveries expire. Fast failure classification, an alert, and an automatic disable after a threshold put the broken configuration in front of a human sooner. The Standard Webhooks spec recommends notifying consumers through another channel (such as email) and disabling an endpoint that fails consistently over a long period.
- Data exposure. Continuing to push sensitive payloads to an endpoint whose owner has deliberately revoked access or retired it is a data-minimization problem as well as a waste of resources.
Implementing Exponential Backoff, Full Jitter, and Circuit Breakers
For legitimate transient errors (5xx, timeouts, and 429), combine three mechanisms:
sleep = random(0, min(cap, base × 2^attempt))
4. Post-Replay Verification: Proving Downstream State Converged Without Double Side Effects
A dashboard showing “0 messages in the DLQ” does not prove recovery succeeded. A replay can report 100% 200 OK while silently failing to mutate records, for example because a stale-timestamp check rejected the write. It can also execute duplicate financial operations because the endpoint lacked an idempotency guard.
Post-replay verification needs evidence from three layers: delivery logs, the idempotency store, and downstream state records.
Layer 1: Idempotency Keys and Stale-Event Protection
Before any replay, every consumer should enforce idempotency using the sender’s stable event identifier, such as Stripe’s event id or the webhook-id header. Avoid “check-then-act” patterns (a SELECT followed by an INSERT), which race under concurrent replay load. Use a database uniqueness constraint and write the idempotency record in the same transaction as the business mutation.
The following example uses PostgreSQL syntax:
CREATE TABLE processed_webhook_events (
event_id VARCHAR(255) PRIMARY KEY,
event_type VARCHAR(100) NOT NULL,
entity_id VARCHAR(255) NOT NULL,
event_created_at TIMESTAMPTZ NOT NULL,
processed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
replay_batch_id VARCHAR(100) NULL,
status VARCHAR(32) NOT NULL -- 'COMPLETED', 'SKIPPED_STALE', 'ESCALATED'
);
For each incoming or replayed event:
- Begin a transaction and run
INSERT INTO processed_webhook_events ... ON CONFLICT (event_id) DO NOTHING. - If zero rows were inserted, the event was already handled. Commit or roll back, return
200 OK, and increment adeduplicated_hitmetric. In PostgreSQL, a concurrent duplicate waits on the unique index until the first transaction commits or rolls back, so two workers can’t both proceed. - Apply the business mutation with a guard against stale data, for example
UPDATE orders SET ..., last_event_at = $ts WHERE id = $id AND (last_event_at IS NULL OR last_event_at < $ts). If no row is updated, record the event asSKIPPED_STALEand return200without regressing state. - Commit. If the process crashes mid-way, both the idempotency row and the mutation roll back, so the event stays eligible for retry. Avoid a separate “processing” marker that would cause a crashed attempt to be treated as complete.
Three caveats matter in practice:
- Timestamps are a heuristic, not an ordering guarantee. Event timestamps are often coarse (frequently whole seconds), so two events can tie. Providers also don’t guarantee delivery order. Prefer a provider-supplied version or sequence number when one exists. When a stale-versus-fresh decision is ambiguous, fetch the current object from the provider’s API and reconcile to that.
- External side effects can’t be rolled back by your database. Emails, payment captures, and calls to other services need their own protection. Use a transactional outbox, and pass idempotency keys to downstream APIs that support them (Stripe’s API accepts an
Idempotency-Keyheader, for example). - Retention matters. Standard Webhooks suggests caching webhook IDs briefly for replay-attack defense, and OWASP recommends keeping them for at least twice the timestamp tolerance. That is not enough for recovery. Keep event IDs for at least as long as the longest provider retry or manual-redelivery window you depend on (30 days for Stripe’s resend and List Events paths, for example).
Layer 2: The Four-Point Post-Replay Audit Checklist
Once the replay batch drains, run a structured audit before declaring the incident resolved.
1. Ingestion-to-Execution Parity Check
Compare the set of unique event_ids dispatched in the replay window against your persistence table. Every dispatched ID should resolve to exactly one terminal outcome: processed (COMPLETED), already processed (deduplicated), skipped as stale (SKIPPED_STALE), or routed to the exception queue (ESCALATED). Any dispatched ID with no outcome is a silent drop. Investigate ingress middleware first: payload size limits, WAF rules, and signature-verification rejections are the usual culprits.
2. Duplicate Side-Effect Invariant Queries
Run SQL assertions against downstream tables to confirm that no duplicate side effects occurred during the replay window:
- Financial or ledger invariant. No single source event should map to more than one ledger entry or fulfillment order.
SELECT source_event_id, COUNT(*)
FROM ledger_transactions
WHERE created_at >= :incident_start
GROUP BY source_event_id
HAVING COUNT(*) > 1;
- Notification invariant. Cross-check outbound email and SMS logs by
entity_idand template to ensure customers did not receive duplicate receipts or notices.
3. Cross-System State Convergence (Diff Audit)
Compare your local database against the provider’s API for every entity touched by the replay. If that population is too large, use a random sample plus full checks on high-value records. Compare:
- Entity counts created in the incident window.
- Aggregate monetary totals against the provider’s reports (for example, payout or settlement reports).
- Terminal states and versions (
status,updated_at,version) for each touched entity.
4. Sign-Off and Runbook Closure
Close the incident only when every item in the recovery manifest has an explicit terminal disposition (RECONCILED, DEDUPLICATED, SKIPPED_STALE, or ESCALATED_TO_MANUAL_EXCEPTION), and error rates and consumer lag have returned to baseline. Also confirm that no automatic provider retries are still scheduled for events you processed by hand, or that your idempotency layer will absorb them.
Summary Checklist for Incident Commanders
- Contain and scope. Define the exact incident start and end times, the last good checkpoint, and the failure mode before touching replay controls.
- Filter, don’t flood. Prefer filtered bulk replay with explicit rate limits over blind full DLQ re-drives, and protect live traffic while you do it.
- Know each provider’s window. Stripe’s manual resend reaches back 15 days in the Dashboard and 30 days via CLI. GitHub redelivery covers 3 days and nothing is automatic. Shopify gives up after about 4 hours of retries. Plan catch-up jobs for anything beyond those windows.
- Classify failures deliberately. Back off with jitter on transient errors. Park auth, contract, and routing failures for human attention and replay them after the fix instead of discarding or hammering them.
- Reconcile extended gaps by state. Use source-of-truth pull APIs with overlap windows, and reconcile current entity state rather than blindly replaying stale transitions.
- Prove convergence. Verify atomic idempotency, stale-event protection, zero duplicate side-effect invariants, and a diff audit against the provider before closing the incident ticket.
Sources
- Stripe: Receive Stripe events in your webhook endpoint and Manage webhook endpoints and process undelivered events
- Svix: Retries
- Standard Webhooks: Specification
- GitHub: Redelivering webhooks
- Shopify: Troubleshoot webhooks
- Twilio: Webhook connection overrides
- Hookdeck: Retry events
- AWS: How EventBridge retries delivering events, SQS dead-letter queue redrive, Exponential Backoff and Jitter, Timeouts, retries, and backoff with jitter
- OWASP: Webhook Security Cheat Sheet