Learning path: Your first WhatsApp Cloud API integrationStep 4 of 7

WhatsApp· 5 min read

WhatsApp message statuses: sent, delivered, read and failed


A WhatsApp Cloud API message moves through sent, delivered and read, or ends at failed, and Meta reports each step in a separate status webhook. Store the furthest status a message has reached and ignore any webhook that would move it backwards. Webhooks can repeat or arrive late, the delivered step can be skipped, and read may never come.

What each status means

Meta’s status webhook reference defines five values for the status field:

Status Meta’s definition WhatsApp UI equivalent
sent “the message was successfully sent from our servers” One checkmark
delivered “message was successfully delivered to the WhatsApp user’s device” Two checkmarks
read “the message was displayed in an open chat thread in the WhatsApp user’s device” Two blue checkmarks
played “the first time a voice message is played by the WhatsApp user’s device” Blue microphone
failed “failure to send or deliver the message to the WhatsApp user’s device” Red error triangle

None of these is the response to your send request. Meta’s send guide says that response “only indicates that the API successfully accepted your request”, and “it does not indicate successful delivery of your message” (send messages). The id in that response, the wamid, is the key that ties every later status webhook to your message. Store it before you do anything else with the send result.

When each status arrives

Status webhooks come through the messages field with a statuses array in place of a messages array. Each one carries id, status, timestamp and recipient_id. The timestamp is “Unix timestamp indicating when the webhook was triggered” (status webhook reference). Meta says “each outgoing message can have up to three separate webhooks (one for a status of sent, one for delivered, and one for read)” (messages webhook reference).

“Up to three” means some messages get fewer. Meta documents one case. A status counts as read only once delivered. But if the user has the chat open when the message lands, “the message is both delivered and read at the same time”. Then “the ‘delivered’ webhook is not sent because it’s implied that the message was delivered since it was read” (status webhook reference). Code that waits for delivered before it accepts read will wait forever on those messages.

read needs the user to open the chat, so a message can stay at delivered indefinitely. Treat a missing read as no information. Don’t flag it as a failure and don’t resend.

A message that never reaches the device has a deadline. Meta retries undelivered messages for a time-to-live of 30 days for most messages and 10 minutes for authentication templates. No delivered webhook before the TTL runs out means Meta’s advice is to “assume the message was dropped”. Failures can lag too, as “there could be a minor delay before you receive the webhook” (send messages).

Why statuses arrive out of order

Meta’s webhook pages do not promise that status webhooks reach you in the order they happened. If your endpoint misses one, Meta “retries delivery with decreasing frequency” for up to 7 days. “These retries can result in duplicate webhook notifications” (webhooks overview). A sent webhook that failed at 10:00 and succeeded on retry at 10:05 lands after the read that went through at 10:01. Your server adds its own reordering when it runs several workers in parallel.

So the order your handler sees is not the order of events. A last-write-wins update shows a read message as sent. Webhooks that arrive out of order covers the inbound side of the same problem.

The failed status and its errors array

A failed webhook carries an errors array. Each entry has code, title, message, error_data.details and href. Meta’s example is a marketing message held back with code 131049:

"errors": [
  {
    "code": 131049,
    "title": "This message was not delivered to maintain healthy ecosystem engagement.",
    "message": "This message was not delivered to maintain healthy ecosystem engagement.",
    "error_data": {
      "details": "In order to maintain a healthy ecosystem engagement, the message failed to be delivered."
    },
    "href": "/documentation/business-messaging/whatsapp/support/error-codes"
  }
]

Store code as an integer and title as text. Route on the code. Meta’s reference says title and message carry the same text, written for people. The error code reference says which codes are worth a retry. Errors that are not about one message, such as app or account problems, arrive elsewhere, in entry.changes.value.errors (messages webhook reference).

A status table that never moves backwards

Give each status a rank and update only when the incoming rank is higher. failed ranks above sent and below delivered. A delivered or read webhook proves the message reached the device, so a late failed must not overwrite it.

CREATE TABLE outbound_messages (
  wamid       text PRIMARY KEY,
  status      text    NOT NULL,
  status_rank integer NOT NULL,
  status_ts   bigint  NOT NULL,   -- Meta's timestamp, Unix seconds
  error_code  integer,
  error_title text
);

Run this for every entry in the statuses array. Bind $1 to $5 to id, status, timestamp, errors[0].code and errors[0].title.

INSERT INTO outbound_messages (wamid, status, status_rank, status_ts, error_code, error_title)
VALUES (
  $1, $2,
  CASE $2 WHEN 'sent' THEN 1 WHEN 'failed' THEN 2 WHEN 'delivered' THEN 3
          WHEN 'read' THEN 4 WHEN 'played' THEN 5 ELSE 0 END,
  $3, $4, $5
)
ON CONFLICT (wamid) DO UPDATE
SET status      = EXCLUDED.status,
    status_rank = EXCLUDED.status_rank,
    status_ts   = EXCLUDED.status_ts,
    error_code  = EXCLUDED.error_code,
    error_title = EXCLUDED.error_title
WHERE outbound_messages.status_rank < EXCLUDED.status_rank;

In PostgreSQL, “only rows for which this expression returns true will be updated” (INSERT). A duplicate webhook has the same rank and changes nothing, so the query also absorbs Meta’s retries. In n8n, paste it into a Postgres node with operation Execute Query and pass the five values under Options > Query Parameters (Postgres node).

The guard drops data on purpose, so log every raw status payload to a separate append-only table as well. You need it for billing. The pricing object is “only included with sent status, and one of either delivered or read status” (status webhook reference). A guarded table keeps one row per message and loses which webhook carried the price.

Statuses on a QR connection

A QR connection drives a WhatsApp Web session, so statuses come from that session and reach you through your provider’s webhook. The names, the set of statuses and the shape of a failure are whatever the provider documents. None of the Cloud API fields above, such as errors[].code or pricing, can be assumed. Neither can Meta’s TTL or retry schedule. Map the provider’s statuses onto the same ranks and keep the guard; out-of-order and duplicate delivery are risks on any webhook stream.

Z-API Omni offers the QR connection and Meta’s official API in the same account, with webhooks included (View documentation).

Z-API Omni team