# Sending Messages & Tracking Status

Canonical: https://docs.bluehola.com/docs/guides/messaging
OpenAPI: https://docs.bluehola.com/openapi.yaml

The `202 Accepted` from `POST /v1/messages` only means the platform has accepted the request — not that it was delivered, and not even that it was submitted to Meta. To track the real status you must poll `GET /v1/messages/{id}` or receive the status webhooks.

## How statuses progress

| Status        | Meaning                                                                                                                             |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `accepted`  | The platform has accepted the request; nothing has been submitted to Meta yet.                                                                                                |
| `sending`   | Being submitted to the appropriate Meta messaging endpoint.                                                                                                      |
| `submitted` | Meta accepted it and returned a `wamid`, but no status callback has arrived yet. **This is not the same as "sent"** — in Meta's documentation `sent` is a separate status callback.                 |
| `sent`      | A Meta status callback confirms it reached the carrier network the user's device is on.                                                                              |
| `delivered` | Delivered to the user's device.                                                                                                 |
| `read`      | The user has read it. **This can arrive without a preceding `delivered`** — when the user happens to be sitting in the chat window, Meta omits the delivered callback. Do not assume the statuses always arrive as a complete sequence. |
| `failed`    | Terminal. Check the `error` field returned by `GET /v1/messages/{id}` (see the message failure code table on the [Error Codes](error-codes.md) page).                                    |

Statuses only move forward — a late or duplicate callback will never push one backwards (a message already at `delivered` will not revert to `sent`).

```mermaid
stateDiagram-v2
    [*] --> accepted : POST /v1/messages returns 202
    accepted --> sending : platform starts submitting
    sending --> submitted : Meta accepts and returns a wamid
    submitted --> sent : Meta status callback
    sent --> delivered : delivered to the user's device
    delivered --> read : the user reads it
    sent --> read : Meta omits delivered when the user is in the chat window
    sending --> failed : failure during submission
    submitted --> failed : failure during delivery
    read --> [*]
    failed --> [*]
```

The `sent --> read` edge in this diagram is the branch that gets missed most often: **do not assume the statuses always arrive as a complete sequence**.


## Idempotency and rate limits

Generate one stable `Idempotency-Key` (≤200 characters) per business event: within the current authorization scope, a repeated key returns **the original** message rather than sending another one, which makes it the only safe way to retry after a network timeout. By default each API Key's account is limited to 600 messages per minute; exceeding that returns `429 RATE_LIMITED`, and you simply back off and retry.

## The 24-hour customer service window

More than 24 hours after the customer last messaged you, only approved **template messages** may be sent — free-form content is no longer allowed. The platform makes a local determination before persisting anything: free-form messages it is certain are outside the window return `409 WHATSAPP_24H_WINDOW_EXPIRED` immediately (with `details.customerAction` giving the next step), without wasting a credit reservation. But that local check only covers the "definitely closed" case — a message the platform believes is inside the window when it has actually closed can still be rejected by Meta, in which case it falls through to the normal message failure code path.

## Binding parameters in template messages

The `parameters` inside `components` must match the placeholders declared when the template was created **exactly** in count and order, or Meta returns a parameter mismatch error. Before sending a template, the platform verifies it has been approved (APPROVED). Template messages are not bound by the 24-hour window, and are the only message type available once it has closed.

## Marketing template delivery

For a template whose category is `MARKETING`, BlueMedia submits to Meta’s Marketing Messages API. This applies regardless of the WABA’s recorded onboarding status. Meta uses Marketing Messages delivery for an onboarded WABA and automatically falls back to Cloud API for a WABA that has not signed the terms (`product_policy: CLOUD_API_FALLBACK`). Other message types and template categories keep their normal Cloud API route. The request to BlueMedia remains `POST /v1/messages`. See [WABA status and onboarding](../assets-phone-numbers/wabas.md).

## Supported message types

`POST /v1/messages` accepts 11 values for `type`, with the content carried in a field of the same name:

| type | Purpose |
| ---- | ---- |
| `text` | Plain text (turn on `preview_url` for link previews). **Used when `type` is omitted.** |
| `template` | An approved template message. The only type available once the 24-hour window has closed. |
| `image` / `video` / `audio` / `document` / `sticker` | Media messages. |
| `interactive` | Buttons, lists, CTA URLs, Flows, location requests, address collection, contact information requests — the whole `interactive` object is passed through to Meta verbatim, so every subtype Meta supports can be sent. `request_contact_info` is checked locally first: it needs a non-blank `body.text` and `action: { name: "request_contact_info" }`. |
| `location` | Send a geographic location (`latitude` / `longitude` required). |
| `contacts` | Send contact cards — at most 257 in one message. |
| `reaction` | React to an existing message with an emoji (`message_id` must start with `wamid.`). |

For the required and optional fields of each type, see [Submit Outbound Message](../messaging/post-v1-messages.md). A misshapen request returns `400` **before anything is persisted** and never enters the asynchronous send queue.

## Media messages

There are two ways to reference media, and you must give **exactly one**:

- `id`: upload first via `POST /v1/media?phoneNumberId=pn_...` to obtain a Meta media id. **The upload endpoint checks size per media type**, matching Meta's own limits (roughly 5 MB images, 16 MB audio/video/documents — the platform caps documents stricter than Meta's own 100 MB — and 100 KB static / 500 KB animated WebP stickers); a file over its type's limit returns `400` before it ever reaches Meta.
- `link`: a URL Meta can reach publicly, which Meta fetches itself. **Documents over 16 MB have to go this way** (Meta allows up to 100 MB only through `link`); so does anything else this upload endpoint rejects for size.

Giving both or neither is a `400` (`provide exactly one of \`id\` or \`link\``).

Size for media sent by `id` is already checked at upload time (see above). Format is never pre-checked, and neither size nor format is pre-checked for media sent by `link` — both are enforced by **Meta at delivery time**; the send endpoint itself does not pre-check them, so an oversized or malformed message gets a 202 first and only later turns failed via a status callback. Meta media ids typically expire after a few days, so do not treat one id as a long-term asset library; temporary download URLs expire after 5 minutes, so use the `GET /v1/media/{id}/content` proxy download for long-term storage.

## Read receipts and typing indicators

`POST /v1/messages/read` marks an inbound message as read, optionally accompanied by a "typing" indicator (valid for about 25 seconds, or until the other party receives your next message). It talks directly to Meta's real-time endpoint, incurs no charge and consumes no send quota. Note that it is entirely separate from the inbox's `POST /v1/conversations/{id}/read`, which only clears the platform's local unread count; the two are not linked.

## Conversations that start from an ad

When a customer arrives by clicking a "Click to WhatsApp" ad, their first message carries the ad click id, which the platform stores. To make Meta's ads dashboard attribute conversions to that ad, you need to report the conversion events back — see [Ad Attribution & Conversion Reporting](ctwa-attribution.md).

## When billing happens

Meta charges on **delivery**, but the platform settles as soon as Meta accepts the message and returns a `wamid`. If a later status callback confirms `failed`, the platform automatically reverses that charge against the credit account (idempotently — it will not reverse twice). So a message that was accepted but failed to deliver ends up costing nothing, with no manual work. See [Billing & Credit Line](billing.md) for details.
