Out-of-order message statuses: how to handle them

Meta documents no order among sent, delivered and read, and delivered can be skipped. Use a state-advance rule that accepts delays and repeats.

A support dashboard shows checkmarks that only advance: one, two, two blue. The real world of webhooks is less polite. Status events can arrive repeated, late, in a different order and, in the case of delivered, sometimes not at all. This article proposes a simple rule for your code that always yields the correct state, regardless of the order in which events show up.

What the documentation guarantees and what it does not

Meta's documentation guarantees no arrival order among statuses. The pages consulted describe each status and say a message can have up to three webhooks, for sent, delivered and read, but they do not say these arrive in that sequence nor do they address a missing status. The right attitude is to design your code without depending on order.

There is one guarantee that helps: the documentation explains that read only occurs if the message was delivered. When the user reads the message the instant it arrives, the delivered webhook is skipped, because delivery is implied by the read event. So seeing read without having seen delivered is not an anomaly; it is an expected case.

Add retries on top. A sent webhook that failed on the first attempt can be resent after delivered has already arrived. Meta resends with decreasing frequency for up to 7 days, and CRPRO Hub resends for about four, so an old status can show up long after a newer one.

The problem: overwriting state with the latest event

The typical mistake is storing the state of every event that arrives, always overwriting. It works in tests, where everything arrives in order. In production, a late sent that arrives after a read makes the message "go back" to one checkmark, and the operator thinks the customer has not seen something they already read.

The same mistake appears in metrics. If you count deliveries per event rather than per message, a retry of delivered inflates the delivery rate. And whoever computes delivery times by arrival order, rather than by the payload timestamp, measures the delay of their own queue instead of WhatsApp latency.

A concrete example: monotonic state advance

The rule is that state only advances. Give each status a rank: sent is 1, delivered is 2 and read is 3, with played at the same level as read. On receiving an event, compare its rank with the current state's; if lower or equal, ignore it; if higher, advance. The final result is the same for any permutation of the events.

const RANK = { sent: 1, delivered: 2, read: 3, played: 3 } // failed stays outside the ranking: handled separately function aplicarStatus(atual, novo) { if (novo.status === 'failed') { return atual.estado === 'read' ? atual : { ...atual, estado: 'failed', erro: novo.errors?.[0] } } if ((RANK[novo.status] ?? 0) <= (RANK[atual.estado] ?? 0)) return atual // late or repeated return { ...atual, estado: novo.status, [novo.status + '_em']: novo.timestamp } }

Three decisions are built into that snippet. A late or repeated event changes nothing, which gives idempotency for free on statuses. A read without a previous delivered is accepted without conflict, because read's rank is higher. And the stored timestamp is the payload's, not the arrival time.

Failed needs its own handling, because it is not a rung on the same ladder. If the message was already read, a later failed is incoherent, and the code above keeps read. Otherwise it stores the failure with the error. If your product lets a later event correct a failure, adjust the rule, but only after seeing that happen in real data: it is not documented.

How to handle the status that never arrives

Define a tolerance period instead of treating absence as an error. If the message stayed at sent and delivered never arrived, the reason may be a switched-off device. Alerting in the first hour creates noise. Alerting when the state is still sent after a period you choose, based on your own data, is more useful.

For important messages, such as an access code, the period must be short and the action decided in advance: resend through another channel, notify the operator or open a ticket. For routine messages, an aggregate metric is enough: the share of messages that have not progressed past sent after X hours.

  • State only advances: ignore events with a lower or equal rank.
  • Read without delivered is valid: reading implies delivery.
  • Use the payload timestamp for timings, not the arrival time.
  • A missing status is not an error: wait for a period chosen with your own data.
  • Handle failed separately, and record the error code.

Testing with shuffled sequences

Test the rule by feeding it every permutation of a small set of events and asserting the same final state. With sent, delivered and read there are only six orderings, so the test is cheap and exhaustive. Add duplicates of each event and a late sent after read, and you cover the cases that production will eventually produce. If the advance rule is a pure function, as in the snippet, the test needs no database and no network.

A second test worth writing replays the same list of events twice. The second pass must change nothing. That single assertion catches most idempotency bugs in status handling, including the ones introduced later by someone who "simplifies" the comparison.

Ordering, queues and concurrency

If several workers consume the queue in parallel, two statuses of the same message can be processed at the same time, and the result depends on which write finishes last. The advance rule must be applied atomically in the database, for example with a conditional UPDATE that changes the row only when the new rank exceeds the stored one. That way even a race between workers ends in the right state.

It is the same principle as deduplication: turn the decision into a single atomic operation instead of read, decide, write. The event list is on the CRPRO Hub webhooks page, and the first authenticated calls are in the quickstart.

Frequently asked questions

Do statuses always arrive in the order sent, delivered, read?

There is no documented ordering guarantee. Retries can delay an event, and delivered can be skipped when the message is read as soon as it arrives.

Why did I get read without receiving delivered?

According to the documentation, when the user reads the message on arrival, the delivered webhook is skipped because delivery is implied by the read.

What do I do if a message stays at sent?

Wait a period defined with your own data before alerting. The documentation does not define when a missing delivered becomes a problem.

How do I stop a late status from reverting the state?

Give each status a rank and advance the state only when the new rank is higher. Make the comparison atomic in the database.

Fontes

Documentação oficial da Meta, conferida em 31 de outubro de 2026.