Boundlayer
WebhooksSaaS ArchitectureBackend EngineeringAPI SecurityEvent-Driven Systems

Reliable Webhooks for SaaS: Signatures, Retries, Idempotency, and Replay

Build reliable webhook systems with signed requests, durable outbox and inbox patterns, idempotent processing, safe retries, controlled replay, SSRF defenses, and reconciliation.

11 min read

By BoundLayer Engineering Team

BoundLayer is a senior engineering partner for SaaS, fintech, AI automation, cloud infrastructure, legacy modernization, Web3, IoT, GPU computing, and data systems.

Webhooks are easy to demonstrate: send an HTTP request when something happens. They become a production system when a customer endpoint times out, an event arrives twice, a deploy interrupts processing, or support needs to recover a delivery without charging a customer twice.

The central design fact is simple: an HTTP response proves only that one request reached a particular point. It does not prove that the business workflow completed exactly once. Reliable integrations need durable event capture, authenticated delivery, idempotent processing, explicit recovery, and reconciliation against the system of record.

That reliability problem remains visible across current provider guidance. GitHub documents that webhook handlers should respond quickly, validate a secret, and handle event types deliberately; it also notes that failed deliveries are not automatically redelivered. The Standard Webhooks initiative is working toward common signing and delivery conventions because provider-specific implementations vary. These patterns apply whether your SaaS product sends events to customers or consumes events from payment, identity, messaging, and data platforms.

First decide which side of the webhook you own

Webhook architecture has two distinct roles:

  • Publisher: your product emits event notifications to customer endpoints.
  • Subscriber: your product receives notifications from an external provider.

Both roles need authentication, observability, retries, and recovery, but their failure modes differ. A publisher must retain events and deliver them to many independent receivers. A subscriber must authenticate external requests, deduplicate them, and safely update internal state.

If your system does both, model those as separate pipelines. A single generic “webhook handler” tends to blur ownership, retry rules, and security controls.

A reliable publisher architecture

Business transaction
        |
Database transaction + outbox record
        |
Outbox relay / event broker
        |
Durable delivery record per endpoint
        |
Worker pool -> signed HTTPS POST -> customer endpoint
        |                              |
Attempt log / retry schedule       2xx acknowledgment
        |
Dead-letter state and controlled replay

The outbox pattern prevents a common loss window: the business change commits, then the process crashes before publishing the event. Write the domain change and outbox row in one database transaction. A relay later publishes the event and marks the outbox record as dispatched. For data pipelines already using change data capture, a CDC stream may serve a similar handoff role; see our guide to reliable CDC pipelines.

Persist the event before attempting network delivery. Keep an immutable event ID and versioned payload envelope. Then create delivery records scoped to each subscribed endpoint. One customer's failing server should not block delivery to everyone else.

For each attempt, record the endpoint, event ID, attempt number, start time, response status, latency, and a safely truncated or classified error. Store sensitive payloads only as long as needed and encrypt them at rest. Never include signing secrets in delivery records or logs.

Retry without creating a retry storm

Treat network timeouts, connection failures, 429, and most 5xx responses as potentially transient. Treat permanent authorization or endpoint configuration errors as conditions to surface to the customer rather than retrying at full speed forever.

A typical retry policy uses exponential backoff with jitter, a maximum attempt duration or event age, and endpoint-level circuit breaking. Honor a provider's Retry-After when appropriate. Jitter prevents many endpoints that failed together from retrying at the same instant.

Do not assume every webhook provider retries. GitHub's documentation says failed deliveries are not automatically redelivered; applications need an operator process or scheduled recovery job. Design from the exact provider contract, not from a generic expectation of “at least once.”

The delivery guarantee should be stated plainly:

  • delivery may be attempted more than once;
  • the same event ID is stable across retries where the provider contract guarantees it;
  • ordering may not be guaranteed;
  • a successful HTTP response means the receiver acknowledged the delivery, not necessarily that its downstream work finished;
  • retention and manual replay windows are bounded and documented.

Avoid promising “exactly once” over HTTP. You can create exactly-once business effects for a bounded operation using transactions and idempotency, but the transport itself can repeat or lose acknowledgments.

Sign requests over the exact bytes you send

For a publisher, sign the raw request body with a per-endpoint secret using a maintained library or a documented interoperable scheme. Include a timestamp and delivery ID in the signed material when the chosen protocol supports them. Send the signature and timestamp in headers, use HTTPS, and provide a key-rotation process with a short overlap window.

For a subscriber, verify the signature against the raw bytes before parsing or acting on the payload. Parsing and reserializing JSON can change whitespace, property order, or number formatting and invalidate a legitimate signature. Compare signatures using a constant-time function from a standard cryptographic library, not a normal string equality operator.

Timestamp freshness checks help limit replay of captured requests only when the timestamp is included in the authenticated signature. A delivery ID header that is not covered by the signature can help deduplication but does not, by itself, provide cryptographic replay protection. Follow the provider's precise signing protocol rather than applying a generic recipe.

The GitHub webhook security guidance recommends a webhook secret and HTTPS, and its delivery ID remains the same when an event is redelivered. The Standard Webhooks verification reference shows a scheme that signs the message ID, timestamp, and payload together.

A safe subscriber pipeline

HTTPS request
    |
Enforce method and payload-size limit
    |
Read raw body and verify provider signature
    |
Validate timestamp / delivery ID / event type
    |
Insert delivery into durable inbox with unique key
    |
Return 2xx after durable acceptance
    |
Async worker -> apply idempotent business transition
    |
Record outcome, retry safe failures, alert on terminal failure

Keep the ingress path small. It should validate what is necessary to accept responsibility for the event, write the payload or a protected reference to durable storage, and acknowledge promptly. Process expensive business logic asynchronously when the provider's timeout budget is short.

Return a success response only after the event is durably accepted or fully processed. If a queue is unavailable and the request was not persisted, return a retryable failure. A 200 followed by an in-memory background task is a silent-loss risk if the process exits.

Idempotency has two layers

Create an inbox or processed-event table with a unique key based on the provider's stable event or delivery identifier. The insert and state transition should be coordinated so two concurrent copies cannot both perform the effect.

But transport-level deduplication is not enough. Providers may emit two distinct events describing the same business transition, or an integration may map multiple provider events to one action. Add business-level idempotency as well:

  • enforce unique payment or invoice transitions in the database;
  • use an idempotency key for external API calls;
  • make email, provisioning, and credit-grant actions independently repeat-safe;
  • persist the workflow outcome before acknowledging downstream completion.

An authenticated duplicate that was already accepted should normally receive a success response without repeating side effects. The receiver's retention window for event IDs should cover the provider's retry and replay window.

Plan for out-of-order and stale events

An event usually describes a fact that happened, not a globally ordered command. Delivery can be delayed, concurrent, or retried after a later event has already been applied.

Do not infer order from timestamps unless the provider documents a reliable sequence contract. For state synchronization, prefer one of these strategies:

  • fetch the current object from the provider after receiving an event;
  • apply only monotonic versions or sequence numbers with documented semantics;
  • store event history and derive state deterministically;
  • reject stale transitions and schedule a reconciliation read.

Do not let subscription.updated arriving after subscription.deleted recreate a deleted subscription just because it was processed later. Make state transitions explicit and test them under reordered delivery.

Replay must be a product feature, not a database edit

Operators need a way to inspect failed deliveries and retry them without manually editing production records. A useful delivery console shows:

  • event ID, type, creation time, and schema version;
  • endpoint and tenant;
  • every attempt, response status, duration, and safe error summary;
  • current retry schedule and terminal state;
  • whether the event was acknowledged or only accepted;
  • an audited replay action with actor and reason.

Replay should preserve the original event ID so receivers can deduplicate it. Offer dry-run or preview for high-impact workflows, and check whether the business effect already occurred before retrying. If payloads can contain personal or financial data, mask them by default and tightly control access.

BoundLayer's durable workflow orchestration guide covers long-running retries and checkpoints. A webhook delivery ledger complements that workflow by making the network boundary and each attempt visible.

Monitor business outcomes, not only HTTP status

Useful publisher metrics include delivery success by endpoint and event type, age of the oldest pending event, retry distribution, 429 and 5xx rates, dead-letter count, and time to recover after an endpoint outage.

Useful subscriber metrics include signature failures, accepted and deduplicated deliveries, queue lag, processing latency, stale-version conflicts, terminal errors, and reconciliation mismatches.

Also monitor silence. If an event should occur every hour but none has arrived for a day, a green endpoint uptime check is not enough. Compare provider objects and internal records periodically for critical billing, access, and fulfillment state. The webhook is a notification path; the provider API or internal ledger remains the authority for reconciliation.

Never log secrets, signature headers, or unrestricted payloads. Use structured identifiers and redaction. Alert on repeated signature failures, unusual endpoint traffic, growing delivery age, and sustained divergence between systems.

Protect outbound delivery from SSRF

If customers can enter a callback URL, your delivery worker becomes a potential server-side request forgery (SSRF) client. An attacker may target loopback addresses, cloud metadata services, private network ranges, or internal hostnames.

At endpoint registration and again at connection time:

  • require HTTPS unless a tightly controlled local-development mode exists;
  • resolve DNS and block non-public IPv4 and IPv6 addresses;
  • defend against DNS rebinding by validating the resolved address actually used for the connection;
  • disable redirects or revalidate every redirect destination;
  • restrict ports, response sizes, connection timeouts, and egress destinations;
  • avoid forwarding credentials across redirects or to unrelated hosts.

IP allowlists can be useful for a known provider, but they are not a substitute for signature verification and can become stale when provider ranges change.

A rollout checklist

  1. Define the event contract, event ID, versioning policy, retention, and ordering guarantees.
  2. Add transactional outbox or an equivalent durable publisher handoff.
  3. Add per-endpoint delivery records, backoff with jitter, timeouts, and terminal failure states.
  4. Verify signatures using the provider's raw-body protocol and plan secret rotation.
  5. Add durable inbox deduplication and business-level idempotency at every side effect.
  6. Test duplicate, delayed, reordered, malformed, forged, and oversized deliveries.
  7. Add endpoint health, replay controls, audit logs, and reconciliation for critical state.
  8. Document what a 2xx response means, how long events are retained, and how customers recover them.

Reliable webhooks are not just HTTP callbacks. They are a small event-delivery product with explicit security, durability, retry, observability, and recovery contracts. BoundLayer builds backend integrations and event pipelines that preserve those contracts across payments, SaaS platforms, internal services, and customer endpoints.

Sources and further reading

Are webhook failures or duplicates affecting your integrations?

We design secure webhook producers and consumers with durable delivery, idempotent workflows, observability, and tested recovery paths.

Free consultation

Get a Free 30-Minute Technical Consultation

Share a few details about your project and we'll get back to you within 48 hours with a clear next step.

  • No sales pressure — a senior engineer, not a sales rep
  • Clear next step within 48 hours
  • We can sign an NDA before we talk

By submitting, you agree to be contacted about your request. We respect your privacy and can sign an NDA on request.