Webhook Design: The Fine Points of Reliable Event Delivery

In April we caught a strange complaint pattern in the legacy payment flow our platform inherited: once or twice a month, orders whose payments had been approved by the bank were stuck in the system in "awaiting payment" status. We dug through the logs and saw the picture: during a 40-minute deployment outage one Sunday night, 312 webhooks sent by the payment provider had fallen into the void. The other side hadn't retried, and our side hadn't noticed. 312 customers had paid without getting their orders, and the call center paid the price for it for a week.

Webhooks are the invisible heroes of integrations: while they work, nobody remembers they exist; when they fail, everybody finds out. I've built hundreds of integrations over sixteen years; this post is a distillation of the lessons from those integrations that hurt.

A Webhook Promises "At Least Once," Not "Exactly Once"

This is the first and most important mindset shift. A well-designed webhook provider promises to deliver an event at least once. The natural consequence of that promise: the same event sometimes arrives twice, sometimes five times. Network hiccups, timeouts, the other side's retry logic: they all produce duplicate deliveries, and none of them is a bug; it's how the system is designed.

The receiving side has to be written with this in mind. We've seen systems that issue two invoices and create two shipping labels when the "payment approved" webhook arrives twice. (Once we even saw a system that gave the same customer a welcome discount three times; for some reason, the customer didn't complain.) The name of the solution is idempotency: you store the unique ID each event carries in a processed events table; when the same ID arrives a second time, you return 200 and do nothing. A one-line extra query saves you from duplicate invoices.

Because a webhook is delivered at least once, duplicate events are normal; a system that stores event IDs never processes the same event twice.
A one-line extra query saves you from duplicate invoices.

Respond Fast, Do the Work Later

The classic mistake goes like this: a webhook arrives, and within the same HTTP request, stock is decremented, an email is sent, a record is opened in the ERP... The process takes 25 seconds, the sender times out at 10 seconds, counts the event as failed and sends it again. Now you have both a half-finished operation and a duplicate on the way.

The right pattern is the exact opposite: when a webhook arrives, verify the signature, write the payload as-is to a queue and immediately return 200. Total time: milliseconds. The real work is done by the worker behind the queue, at its own pace and with its own retry logic. This separation is the golden rule for the receiving side; every system that doesn't follow it sooner or later lives through that 312-order Sunday night.

The queue architecture has another bonus: observability. Queue depth alone is a tremendous health indicator: is it piling up or draining, and how many minutes has the oldest event been waiting? Once you put these three numbers on a dashboard and wire them to alerts, you find out your webhook pipeline has a cold before it turns into pneumonia.

Webhook receiving pattern: verify the signature, write the payload to a queue, return 200 immediately and leave the real work to the worker.
The real work is done by the worker behind the queue.

Don't Trust Every Incoming Request

Your webhook endpoint is a door open to the internet, and its URL is guessable. Whatever anyone sends to an endpoint that doesn't verify signatures, your system takes as real. Cases of free shopping via a request that imitates a "payment approved" event are not at all rare in the industry.

Most providers use an HMAC signature: the payload is signed with a shared secret and arrives in a header. When verifying, use the raw body; if you parse the JSON and re-serialize it, the signature won't match, and this is the kind of bug that makes you tear your hair out while debugging. Add a timestamp check as well, so a captured old request can't be replayed.

Take environment separation seriously, too. Finding the test system's webhook pointed at the production endpoint has come up with embarrassing frequency in the audits I've done over the years; I personally cleaned up a case where fake orders were being deducted from real stock. Give every environment its own secret, its own endpoint and its own log stream, and rotate secrets just like passwords.

Let me share a design choice about payloads, too: in sensitive integrations we send "thin" webhooks: the event's ID, type and timestamp, with no data body. The consuming side pulls the details from the API itself. That way, even if a webhook is intercepted in transit, there's no data to leak, and because data is always read in its latest state, the ordering problem softens on its own.

Let me attach the ordering issue here as well: webhooks don't have to arrive in the order they were sent. An "order canceled" event can show up at your door before "order created." Make your decisions based on the timestamp or version number on the event; code that trusts arrival order will sooner or later write the wrong state.

And then there's the insurance nobody talks about: reconciliation. No matter how robustly a webhook is set up, it shouldn't be your only channel of information. In critical integrations, we set up a reconciliation job that runs once a day: records from the last 24 hours are pulled from the other side's API, compared with our side, and any gaps are closed and reported. Even if that 312-order incident happened again, it would now be caught automatically by the next morning at the latest. Webhooks are for speed; reconciliation is for accuracy. The two aren't rivals, they're partners.

If You're the Sender, the Burden Is on You

The other side of the coin: if you're sending webhooks from your own platform to your customers, you're now the one making the reliability promise. We distribute more than two million events a day from our platform to restaurant and logistics integrations; at this scale you can't say "I sent it, the rest is the other side's problem." Here's the minimum framework we've settled on over the years:

  • Retries for failed deliveries at exponentially increasing intervals (1 min, 5 min, 30 min, 2 hr...) for at least 24 hours.
  • A dead letter queue for events that permanently can't be delivered, plus an interface where customers can see and replay them from their dashboard.
  • A unique ID, event type, timestamp and signature on every event.
  • A circuit breaker and automatic notification if a customer's endpoint keeps failing.

And documentation: which events exist, what's the payload schema, what's your retry policy? Recently we've been adding an MCP face to all this as well; the developer on the integrating side (or, frankly, more often their coding agent) can query event schemas and trigger test events from the dashboard. Integration times went from days to hours, because the other side no longer has to email us and wait for an answer to "what exactly does the payload look like?"

Make schema versioning part of this contract, too. Adding a new field to the payload is fair game; deleting an existing field or changing its type is a breaking change and is announced with a separate version. The mirror image of the same discipline falls to the consuming side: ignore unfamiliar fields instead of treating them as errors, so an innocent addition on the other side doesn't bring your system to a halt.

Minimum framework for the webhook sender: exponential retries, a dead letter queue, event envelope fields and a circuit breaker.
If you're the sender, you're the one making the reliability promise.

The 312-order incident had a happy ending: a queue was put in between, an idempotency table was set up, and the lost events were recovered with the provider's replay API. Now, when the same system goes down, events pile up and are processed in order once the system is back up; the call center doesn't even hear about it. If you suspect silent losses like these in your own integrations, start with queue depth and a daily reconciliation report; the weak link usually reveals itself within the first week. I'm always up for commiserating about webhooks; the contact page is open.