# Send messages

Every content type, statuses and media.

`POST /messages` sends a message. It needs `connectionId`, `to` (number in international format, for example `+237600000000`) and **exactly one** content field.

## Content types

| Field | Use |
|---|---|
| `text` | Free text, 4,096 characters at most. |
| `image`, `document`, `audio`, `video` | Media, by `assetId` (see below) or by `url`. Caption and file name are optional. |
| `product` | Meta product card (`catalogId`, `productRetailerId`, optional `body`). |
| `productList` | Product list (`catalogId`, `body`, `sections[].productItems[]`). |
| `template` | Approved template: `{ name, language, components? }`. |
| `smart` | Free text if the 24-hour window is open, otherwise the fallback template: `{ text, template }`. |
| `buttons` | Up to 3 quick-reply buttons. |
| `list` | A list of choices, up to 10 rows. |
| `cta` | A button that opens a web address. |
| `otp` | One-time code, see [the guide](/en/docs/guides/otp). |
| `flow` | WhatsApp Flow (`navigate`, `data_exchange` or `cta`): see [WhatsApp Flows](/en/docs/flows). |
| `callPermissionRequest` | Asks the customer for permission to call them: see [WhatsApp calls](/en/docs/calling). |
| `reaction` | Reaction to a received message. |

```json title="Text"
{ "connectionId": "con_...", "to": "+237600000000", "text": "Your parcel leaves tomorrow." }
```
```json title="Template"
{
  "connectionId": "con_...",
  "to": "+237600000000",
  "template": {
    "name": "order_shipped",
    "language": "en",
    "components": [
      { "type": "body", "parameters": [{ "type": "text", "text": "A-2041" }] }
    ]
  }
}
```
```json title="Buttons"
{
  "connectionId": "con_...",
  "to": "+237600000000",
  "buttons": {
    "body": "Would you like delivery tomorrow?",
    "buttons": [{ "id": "yes", "title": "Yes" }, { "id": "no", "title": "No" }]
  }
}
```
```json title="Smart"
{
  "connectionId": "con_...",
  "to": "+237600000000",
  "smart": {
    "text": "Hello Awa, here are your interview details.",
    "template": { "name": "interview_reminder", "language": "en", "components": [] }
  }
}
```

## The 24-hour window

WhatsApp only accepts a free-form message (`text`, media, buttons, list) within 24 hours of the recipient's last message. Outside it, you need an approved [template](/en/docs/templates). A send outside the window fails with error [131047](/en/docs/errors/131047). To personalise and send in bulk while the window is open, use a [free-form campaign](/en/docs/campaigns).

## The life of a message

The `200` response gives `id`, `wamid` and `status` = `accepted`. This means Meta took the message, not that it arrived. The status then moves to `sent`, `delivered`, `read` or `failed`. Follow it with a [webhook](/en/docs/webhooks) or with `GET /messages/{id}`.

## Send media

Upload the file with `POST /media` (multipart, field `file`), then use the `assetId` you receive in the message. The same file uploaded twice is stored once. Media is kept 30 days in a private vault, then deleted.

```bash
curl -X POST https://hira.localtechstudio.com/api/v1/media \
  -H "Authorization: Bearer pk_live_..." \
  -F "file=@catalog.pdf"
```

## Failures

A `failed` message exposes Meta's error code. The detail of each code and the right reaction are in [Error codes](/en/docs/errors).
