Contact us
Insights

Dealing with webhook delivery out of order

Webhooks can arrive late, twice, or in the wrong order. How to stop an old update overwriting a new one, and catch the ones that never arrive.

The problem

Fast, but not in order

Webhooks are the quickest way to hear about a change: the platform calls your integration the moment an order is paid, edited, or cancelled. But most platforms don’t promise to deliver them in order, or exactly once. A retried “order paid” message can arrive after “order cancelled”. If the integration simply applies each message as it comes, the cancelled order is switched back to paid and sent to the warehouse.

Why it happens

How webhooks end up out of order

Retries

If your endpoint is slow or briefly down, the platform tries again later, after newer messages have already arrived.

Parallel delivery

Platforms send many webhooks at once from different servers, so two changes a second apart can arrive either way round.

Duplicates

A message your endpoint received but didn’t acknowledge in time is sent again.

Gaps

After repeated failures, some platforms give up on a message altogether.

The fix

Four ways to handle out-of-order webhooks

Compare versions before applying

Store the record’s last updated time or version number. Ignore any message older than the one you already hold.

Treat the webhook as a nudge

On any webhook, fetch the current record from the platform’s API and apply that. The latest state always wins.

Record message IDs

Keep the ID of each processed message, so a duplicate is recognised and skipped.

Acknowledge quickly, process later

Reply to the platform at once and process the message from a queue. Fewer timeouts means fewer retries and fewer surprises.

Status changes need extra care

Some changes should only move one way. An order that has been cancelled or dispatched shouldn’t go back to paid because a late message says so. Write down which status changes are allowed, for example paid to dispatched but never cancelled to paid, and reject anything else with a log entry. That rule protects you even when the version check isn’t available.

Catch the webhooks that never arrive

Out-of-order messages are a nuisance; missing ones are worse, because nothing tells you they’re missing. Run a slower check alongside the webhooks that asks the platform for anything changed recently and fills the gaps. For example: an hourly check for orders changed in the last two hours, processed with the same version rules, catches whatever the webhooks missed. Our guide to choosing polling intervals covers how often to run it.

Orders changing status when they shouldn’t?

Tell us which platform sends your webhooks and what goes wrong. A few lines are enough.

Tell us what’s not working