# WhatsApp

> WhatsApp Business Platform numbers through your Meta app, connected with Facebook Login for Business (Embedded Signup).

The permissions each operation needs are in [App Review: WhatsApp](https://docs.koil.co/app-review#whatsapp).

-   The Cloud API keeps no message history and lists no 1:1 conversations, so inbound messages and delivery statuses arrive only as events. The one read is `whatsapp.groups.conversations`, the groups the number is in.
-   Free-form text sends are accepted only inside WhatsApp's 24-hour customer service window.
-   1:1 reactions are `whatsapp.dm.reactions`, one per person per message: `updated` each time a person sets one, the first included, since WhatsApp does not say which is first, and `deleted` when they remove it. A reaction the business sends gets a `whatsapp.dm.statuses` event under a message id the publish does not answer.
-   A person is their business-scoped user id (BSUID, such as `US.13491208655302741918`): a message's `author.externalId`, a status's `recipient.externalId`, and the `containerId` of a 1:1 conversation, which a send takes. Meta shares the phone number only under conditions, as `authorPhoneNumber` or `recipientPhoneNumber`, so never key on it.
-   Group chats are their own surface: `whatsapp.groups.messages` and `whatsapp.groups.statuses`, with the group's id as `containerId`, the participant who sent a message as its `author`, and the one a status reports for as its `recipient`. To reply in a group, publish to `whatsapp.groups.messages` with the message's `containerId`. `whatsapp.groups.conversations` lists the groups the number is in and reads one group's participants, each keyed by BSUID; its events carry only the fields a change states, so read the group with `get` for the rest. Meta opens groups only to Official Business Accounts, and a group message cannot be edited or deleted.

| Collection | Operations | Events | Backfill |
| --- | --- | --- | --- |
| [`whatsapp.dm.messages`](https://docs.koil.co/platforms/whatsapp#whatsapp.dm.messages) | `resolve_attachment`, `publish`, `perform_action` | `created` | no |
| [`whatsapp.dm.reactions`](https://docs.koil.co/platforms/whatsapp#whatsapp.dm.reactions) | `publish`, `delete` | `updated`, `deleted` | no |
| [`whatsapp.dm.statuses`](https://docs.koil.co/platforms/whatsapp#whatsapp.dm.statuses) | _none_ | `created` | no |
| [`whatsapp.groups.messages`](https://docs.koil.co/platforms/whatsapp#whatsapp.groups.messages) | `resolve_attachment`, `publish`, `perform_action` | `created` | no |
| [`whatsapp.groups.statuses`](https://docs.koil.co/platforms/whatsapp#whatsapp.groups.statuses) | _none_ | `created` | no |
| [`whatsapp.groups.conversations`](https://docs.koil.co/platforms/whatsapp#whatsapp.groups.conversations) | `list`, `get`, `update`, `delete` | `created`, `updated`, `deleted` | yes |

## `whatsapp.dm.messages`

1:1 messages between people and the business number. Inbound messages arrive as events only: the Cloud API keeps no history.

### `resolve_attachment`

Get a URL for a file a WhatsApp message carries. WhatsApp serves the file only to the business, so the URL is a Koil link that streams it from WhatsApp; it expires after five minutes.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes | The item that carries the file. |
| `attachmentExternalId` | `string` | yes | The attachment's `externalId`, as the read reported it. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId",
    "attachmentExternalId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The item that carries the file."
    },
    "attachmentExternalId": {
      "type": "string",
      "minLength": 1,
      "description": "The attachment's `externalId`, as the read reported it."
    }
  },
  "additionalProperties": false
}
```

### `publish`

Send a WhatsApp message from the business number to a recipient: inside the 24-hour customer service window, text, or one image, video, audio file, or document with an optional caption, optionally quoting one of their messages; at any time, an approved template, which can start a conversation by phone number.

Submit through `POST /v1/publish-requests` with `collection: "whatsapp.dm.messages"`. These fields go in the item's `args`; `profileId` and `variant` are item fields.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `containerId` | `string` | no | The 1:1 conversation to send into, as a message's `containerId` names it: the person's business-scoped user id (BSUID), such as `US.13491208655302741918`, or a parent BSUID (`US.ENT.…`). A phone number is refused. |
| `recipientPhoneNumber` | `string` | no | With `template` only, in place of `containerId`: the person's phone number in E.164, with or without its `+`, so an `authorPhoneNumber` read from a message goes back as it came, to start a conversation with a person the business has none with. Their replies and this message's statuses name the conversation by BSUID. |
| `text` | `string` | no | Caption/body text for content. |
| `attachments` | `object \| object[]` | no | One image, video, audio file, or document, with `text` as its caption (up to 1,024 characters; audio takes none). Staged, then fetched by WhatsApp from a URL Koil signs. |
| `target` | `object` | no | One thing on the platform outside this item: content, an account, or anything else the platform gives an id or a URL. |
| `previewUrl` | `boolean` | no | Render a link preview for the first URL in the text. |
| `template` | `object` | no | An approved message template and the values that fill its variables. Meta accepts a template outside the 24-hour customer service window, so it can start or reopen a conversation. |

JSON Schema

```json
{
  "type": "object",
  "required": [],
  "properties": {
    "containerId": {
      "type": "string",
      "minLength": 1,
      "description": "The 1:1 conversation to send into, as a message's `containerId` names it: the person's business-scoped user id (BSUID), such as `US.13491208655302741918`, or a parent BSUID (`US.ENT.…`). A phone number is refused.",
      "pattern": "^[A-Z]{2}\\.(ENT\\.)?[A-Za-z0-9]{1,128}$"
    },
    "recipientPhoneNumber": {
      "type": "string",
      "pattern": "^\\+?[1-9][0-9]{1,14}$",
      "description": "With `template` only, in place of `containerId`: the person's phone number in E.164, with or without its `+`, so an `authorPhoneNumber` read from a message goes back as it came, to start a conversation with a person the business has none with. Their replies and this message's statuses name the conversation by BSUID."
    },
    "text": {
      "type": "string",
      "description": "Caption/body text for content."
    },
    "attachments": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "required": [
              "mediaId"
            ],
            "properties": {
              "mediaId": {
                "type": "string",
                "minLength": 1
              },
              "contentType": {
                "type": "string",
                "minLength": 1
              },
              "altText": {
                "type": "string",
                "minLength": 1
              },
              "filename": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255,
                "description": "The name the recipient sees on a document, where the destination shows one. Defaults to the uploaded file's name."
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "sourceUrl"
            ],
            "properties": {
              "sourceUrl": {
                "type": "string",
                "minLength": 1
              },
              "contentType": {
                "type": "string",
                "minLength": 1
              },
              "altText": {
                "type": "string",
                "minLength": 1
              },
              "filename": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255,
                "description": "The name the recipient sees on a document, where the destination shows one. Defaults to the uploaded file's name."
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1,
      "maxItems": 1,
      "description": "One image, video, audio file, or document, with `text` as its caption (up to 1,024 characters; audio takes none). Staged, then fetched by WhatsApp from a URL Koil signs."
    },
    "target": {
      "type": "object",
      "required": [
        "kind",
        "externalId"
      ],
      "properties": {
        "kind": {
          "enum": [
            "whatsapp.dm.messages"
          ]
        },
        "externalId": {
          "type": "string",
          "description": "Platform-owned content identifier.",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "description": "One thing on the platform outside this item: content, an account, or anything else the platform gives an id or a URL."
    },
    "previewUrl": {
      "type": "boolean",
      "description": "Render a link preview for the first URL in the text."
    },
    "template": {
      "type": "object",
      "required": [
        "name",
        "language"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 512,
          "pattern": "^[a-z0-9_]+$",
          "description": "The approved template's name."
        },
        "language": {
          "type": "string",
          "minLength": 2,
          "description": "The language of the template's translation to send, as WhatsApp codes it: `en_US`, `pt_BR`, `fr`."
        },
        "header": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "text"
            ],
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1,
                "description": "The value."
              },
              "name": {
                "type": "string",
                "pattern": "^[a-z_]+$",
                "description": "The parameter's name, without its braces (`first_name` for `{{first_name}}`), for a template whose parameters are named. Omit it for a positional template, whose values go in order."
              }
            },
            "additionalProperties": false
          },
          "minItems": 1,
          "maxItems": 1,
          "description": "The value of a text header's one variable. Templates with a media header are not supported yet."
        },
        "body": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "text"
            ],
            "properties": {
              "text": {
                "type": "string",
                "minLength": 1,
                "description": "The value."
              },
              "name": {
                "type": "string",
                "pattern": "^[a-z_]+$",
                "description": "The parameter's name, without its braces (`first_name` for `{{first_name}}`), for a template whose parameters are named. Omit it for a positional template, whose values go in order."
              }
            },
            "additionalProperties": false
          },
          "minItems": 1,
          "description": "The values of the body's variables."
        },
        "buttons": {
          "type": "array",
          "items": {
            "anyOf": [
              {
                "type": "object",
                "required": [
                  "type",
                  "index",
                  "payload"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "quick_reply"
                  },
                  "index": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9,
                    "description": "The button's zero-based position in the template."
                  },
                  "payload": {
                    "type": "string",
                    "minLength": 1,
                    "description": "Returned as the reply message's `choice.payload` when the person taps the button. Without one, WhatsApp returns the button's label."
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "type",
                  "index",
                  "text"
                ],
                "properties": {
                  "type": {
                    "type": "string",
                    "const": "url"
                  },
                  "index": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9,
                    "description": "The button's zero-based position in the template."
                  },
                  "text": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The value of the URL button's one variable, appended to its URL. Percent-encode special characters."
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "minItems": 1,
          "maxItems": 10,
          "description": "A payload for each quick-reply button that should return one, and the value of each URL button's variable."
        }
      },
      "additionalProperties": false,
      "description": "An approved message template and the values that fill its variables. Meta accepts a template outside the 24-hour customer service window, so it can start or reopen a conversation."
    }
  },
  "additionalProperties": false,
  "anyOf": [
    {
      "required": [
        "text"
      ]
    },
    {
      "required": [
        "attachments"
      ]
    },
    {
      "required": [
        "template"
      ]
    }
  ],
  "if": {
    "required": [
      "recipientPhoneNumber"
    ]
  },
  "else": {
    "required": [
      "containerId"
    ]
  },
  "dependentRequired": {
    "recipientPhoneNumber": [
      "template"
    ]
  },
  "dependentSchemas": {
    "template": {
      "properties": {
        "text": false,
        "attachments": false,
        "target": false,
        "previewUrl": false
      }
    },
    "recipientPhoneNumber": {
      "properties": {
        "containerId": false
      }
    }
  }
}
```

#### Media requirements

An asset that meets everything under _Copied as is_ is published exactly as uploaded. Otherwise Koil converts only what misses, a billed media add-on that needs a paid plan. Anything under _Refused_ fails the publish request, since no conversion fixes it.

| Media | Copied as is | Otherwise converted | Refused |
| --- | --- | --- | --- |
| Image | JPEG or PNG | re-encoded to JPEG | over 5 MB once staged |
| Video | MP4/MOV, H.264 | re-encoded to H.264 in MP4 | over 16 MB once staged |
| Audio | AAC, AMR, MP3, M4A or Ogg | — | any other format; over 16 MB |
| Document | PDF, DOC, DOCX, XLS, XLSX, PPT or PPTX | — | any other format; over 100 MB |

### `perform_action`

Mark a message the person sent, and those before it, as read, showing them a read receipt; `typing_on` also shows that the business is typing, until it replies or for 25 seconds.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes | The person's message, as its `externalId` names it (a `wamid`), from a `created` event. |
| `action` | `"seen" \| "typing_on"` | yes | What to do with the item: `seen` (show the person a read receipt for their messages), `typing_on` (show the person that the profile is typing). |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId",
    "action"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The person's message, as its `externalId` names it (a `wamid`), from a `created` event."
    },
    "action": {
      "enum": [
        "seen",
        "typing_on"
      ],
      "description": "What to do with the item: `seen` (show the person a read receipt for their messages), `typing_on` (show the person that the profile is typing).",
      "x-koil-narrows": "ContentAction"
    }
  },
  "additionalProperties": false
}
```

### Not offered

-   `list`: platform no endpoint
-   `get`: platform no endpoint
-   `update`: platform not supported
-   `delete`: platform not supported
-   `perform_action` `typing_off`: platform not supported — WhatsApp has no call that clears the typing indicator; it clears when the business replies or after 25 seconds.

### Events

-   [`content.whatsapp.dm.messages.created`](https://docs.koil.co/events#content.whatsapp.dm.messages.created)

Backfill: not offered — platform no endpoint.

Item schema

What `list` and `get` return and what events carry as `data`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `containerId` | `string` | yes | The conversation: the same on every message in it, on reads and events alike, so an inbox groups by it. It is TikTok's conversation id, a WhatsApp group's id, and in a 1:1 chat on Instagram, Facebook or WhatsApp the counterpart's own id, since Meta's messaging webhooks carry no conversation id. |
| `target` | `object` | no | The one thing on the platform this item directly responds to: a comment's post, or the comment it replies to; a message's quoted or replied-to message, story or comment; what a reaction reacts to. Absent when the platform reports nothing it responds to. |
| `references` | `object[]` | no |  |
| `text` | `string` | no | Caption/body text for content. |
| `author` | `object` | yes | Platform actor reference for observed content. |
| `ownerAuthored` | `boolean` | no | Whether the Profile's own account wrote it. Absent when Koil cannot tell, which does not mean someone else did. |
| `attachments` | `unknown \| unknown \| unknown[]` | no |  |
| `choice` | `object` | no | The option the person picked instead of typing: a quick reply, a button or a list row a message offered, or one of the account's ice breakers. Its label is the message's `text`, and the message that offered it is `target` where the platform names it. Present where the platform reports the tap, which on Instagram and Messenger is the message's event only: a read of the same message returns its `text` without `choice`. Absent too when the platform withholds the payload (Meta sends a postback's payload only to the app that sent the button), so such a tap reads as typed text. |
| `publishedAt` | `string (date-time)` | no | When the platform published it. |
| `externalId` | `string` | yes | Platform-owned content identifier. |
| `variant` | `"text" \| "image" \| "video" \| "audio" \| "document" \| "sticker" \| "location" \| "contacts" \| "interactive" \| "button" \| "referral" \| "order" \| "system" \| "unsupported" \| "other"` | yes | The Cloud API message `type`. Media types carry one `attachments` entry; `location` carries `location`; `unsupported` is a type the Cloud API cannot deliver (e.g. a poll); `other` is a type Meta added that Koil does not model yet. |
| `authorPhoneNumber` | `string` | no | The person's phone number in E.164 digits, present only when Meta shares it: when the business messaged or called that number, or was messaged or called from it, in the last 30 days, or has it in its contacts. Never a key: it can be absent on one message and present on the next, so identify the person by their BSUID. |
| `location` | `object` | no | Geographic place reference for content. |
| `platformRaw` | `unknown` | no | Optional platform-native payload included only for transient delivery/debug use. |
| `kind` | `"whatsapp.dm.messages"` | yes | The collection that delivered this item. |

## `whatsapp.dm.reactions`

People's reactions to the business number's 1:1 messages, and the business's own reactions to theirs. Inbound reactions arrive as events only: the Cloud API keeps no history.

### `publish`

React to a person's message as the business number. Meta accepts a reaction to a message older than 30 days, deleted, or itself a reaction, and then does not deliver it.

Submit through `POST /v1/publish-requests` with `collection: "whatsapp.dm.reactions"`. These fields go in the item's `args`; `profileId` and `variant` are item fields.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `containerId` | `string` | yes | The 1:1 conversation to send into, as a message's `containerId` names it: the person's business-scoped user id (BSUID), such as `US.13491208655302741918`, or a parent BSUID (`US.ENT.…`). A phone number is refused. |
| `target` | `object` | yes | The message to react to: one the person sent in the last 30 days. |
| `emoji` | `string` | yes | The emoji reacted with, as the platform sent it. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "containerId",
    "target",
    "emoji"
  ],
  "properties": {
    "containerId": {
      "type": "string",
      "minLength": 1,
      "description": "The 1:1 conversation to send into, as a message's `containerId` names it: the person's business-scoped user id (BSUID), such as `US.13491208655302741918`, or a parent BSUID (`US.ENT.…`). A phone number is refused.",
      "pattern": "^[A-Z]{2}\\.(ENT\\.)?[A-Za-z0-9]{1,128}$"
    },
    "target": {
      "type": "object",
      "required": [
        "kind",
        "externalId"
      ],
      "properties": {
        "kind": {
          "enum": [
            "whatsapp.dm.messages"
          ]
        },
        "externalId": {
          "type": "string",
          "description": "Platform-owned content identifier.",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "description": "The message to react to: one the person sent in the last 30 days."
    },
    "emoji": {
      "type": "string",
      "minLength": 1,
      "description": "The emoji reacted with, as the platform sent it."
    }
  },
  "additionalProperties": false
}
```

### `delete`

Remove the business number's own reaction.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `containerId` | `string` | yes | The 1:1 conversation to send into, as a message's `containerId` names it: the person's business-scoped user id (BSUID), such as `US.13491208655302741918`, or a parent BSUID (`US.ENT.…`). A phone number is refused. |
| `externalId` | `string` | yes | The business number's own reaction, as a publish answered it: `{phone number id}:{message id}`. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "containerId",
    "externalId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "containerId": {
      "type": "string",
      "minLength": 1,
      "description": "The 1:1 conversation to send into, as a message's `containerId` names it: the person's business-scoped user id (BSUID), such as `US.13491208655302741918`, or a parent BSUID (`US.ENT.…`). A phone number is refused.",
      "pattern": "^[A-Z]{2}\\.(ENT\\.)?[A-Za-z0-9]{1,128}$"
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The business number's own reaction, as a publish answered it: `{phone number id}:{message id}`."
    }
  },
  "additionalProperties": false
}
```

### Not offered

-   `list`: platform no endpoint
-   `get`: platform no endpoint
-   `resolve_attachment`: not applicable
-   `update`: not applicable — Publishing a reaction again replaces the business's reaction to that message.
-   `perform_action`: not applicable

### Events

-   [`content.whatsapp.dm.reactions.updated`](https://docs.koil.co/events#content.whatsapp.dm.reactions.updated)
-   [`content.whatsapp.dm.reactions.deleted`](https://docs.koil.co/events#content.whatsapp.dm.reactions.deleted)

Backfill: not offered — platform no endpoint.

Item schema

What `list` and `get` return and what events carry as `data`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `target` | `object` | yes | The message reacted to. |
| `containerId` | `string` | yes | The 1:1 conversation of the message reacted to: the person's BSUID, as its messages' `containerId` names it. |
| `emoji` | `string` | no | The emoji reacted with, as the platform sent it. |
| `author` | `object` | yes | Platform actor reference for observed content. |
| `ownerAuthored` | `boolean` | no | Whether the Profile's own account wrote it. Absent when Koil cannot tell, which does not mean someone else did. |
| `publishedAt` | `string (date-time)` | no | When the platform published it. |
| `externalId` | `string` | yes | Platform-owned content identifier. |
| `authorPhoneNumber` | `string` | no | The person's phone number in E.164 digits, present only when Meta shares it: when the business messaged or called that number, or was messaged or called from it, in the last 30 days, or has it in its contacts. Never a key: it can be absent on one message and present on the next, so identify the person by their BSUID. |
| `platformRaw` | `unknown` | no | Optional platform-native payload included only for transient delivery/debug use. |
| `kind` | `"whatsapp.dm.reactions"` | yes | The collection that delivered this item. |

## `whatsapp.dm.statuses`

Delivery and read statuses of messages the number sent. Events only.

### Not offered

-   `list`: platform no endpoint
-   `get`: not applicable
-   `resolve_attachment`: not applicable
-   `publish`: not applicable
-   `update`: not applicable
-   `perform_action`: not applicable
-   `delete`: not applicable

### Events

-   [`content.whatsapp.dm.statuses.created`](https://docs.koil.co/events#content.whatsapp.dm.statuses.created)

Backfill: not offered — platform no endpoint.

Item schema

What `list` and `get` return and what events carry as `data`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `externalId` | `string` | yes | Platform-owned content identifier. |
| `containerId` | `string` | yes | The conversation of the message this status reports on: the recipient's business-scoped user id (BSUID), as that conversation's messages name it. |
| `target` | `object` | yes | The outbound message this status reports on, by the `externalId` its publish request returned. |
| `status` | `"sent" \| "delivered" \| "read" \| "played" \| "failed" \| "other"` | yes | The delivery state this status reports. `other` is a state Meta added that Koil does not model yet. |
| `recipient` | `object` | yes | Platform actor reference for observed content. |
| `recipientPhoneNumber` | `string` | no | The person's phone number in E.164 digits, present only when Meta shares it: when the business messaged or called that number, or was messaged or called from it, in the last 30 days, or has it in its contacts. Never a key: it can be absent on one message and present on the next, so identify the person by their BSUID. |
| `occurredAt` | `string (date-time)` | no |  |
| `conversation` | `object` | no |  |
| `pricing` | `object` | no |  |
| `errors` | `object[]` | no |  |
| `callbackData` | `string` | no |  |
| `platformRaw` | `unknown` | no | Optional platform-native payload included only for transient delivery/debug use. |
| `kind` | `"whatsapp.dm.statuses"` | yes | The collection that delivered this item. |

## `whatsapp.groups.messages`

Messages in WhatsApp groups the business number is in. Inbound messages arrive as events only: the Cloud API keeps no history.

### `resolve_attachment`

Get a URL for a file a WhatsApp group message carries. WhatsApp serves the file only to the business, so the URL is a Koil link that streams it from WhatsApp; it expires after five minutes.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes | The item that carries the file. |
| `attachmentExternalId` | `string` | yes | The attachment's `externalId`, as the read reported it. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId",
    "attachmentExternalId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The item that carries the file."
    },
    "attachmentExternalId": {
      "type": "string",
      "minLength": 1,
      "description": "The attachment's `externalId`, as the read reported it."
    }
  },
  "additionalProperties": false
}
```

### `publish`

Send a WhatsApp message from the business number into a group: text, or one image, video, audio file, or document with an optional caption, optionally quoting one of its messages.

Submit through `POST /v1/publish-requests` with `collection: "whatsapp.groups.messages"`. These fields go in the item's `args`; `profileId` and `variant` are item fields.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `containerId` | `string` | yes | The group to send into, as a message's `containerId` names it: the group's id. |
| `text` | `string` | no | Caption/body text for content. |
| `attachments` | `object \| object[]` | no | One image, video, audio file, or document, with `text` as its caption (up to 1,024 characters; audio takes none). Staged, then fetched by WhatsApp from a URL Koil signs. |
| `target` | `object` | no | One thing on the platform outside this item: content, an account, or anything else the platform gives an id or a URL. |
| `previewUrl` | `boolean` | no | Render a link preview for the first URL in the text. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "containerId"
  ],
  "properties": {
    "containerId": {
      "type": "string",
      "minLength": 1,
      "description": "The group to send into, as a message's `containerId` names it: the group's id."
    },
    "text": {
      "type": "string",
      "description": "Caption/body text for content."
    },
    "attachments": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "object",
            "required": [
              "mediaId"
            ],
            "properties": {
              "mediaId": {
                "type": "string",
                "minLength": 1
              },
              "contentType": {
                "type": "string",
                "minLength": 1
              },
              "altText": {
                "type": "string",
                "minLength": 1
              },
              "filename": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255,
                "description": "The name the recipient sees on a document, where the destination shows one. Defaults to the uploaded file's name."
              }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": [
              "sourceUrl"
            ],
            "properties": {
              "sourceUrl": {
                "type": "string",
                "minLength": 1
              },
              "contentType": {
                "type": "string",
                "minLength": 1
              },
              "altText": {
                "type": "string",
                "minLength": 1
              },
              "filename": {
                "type": "string",
                "minLength": 1,
                "maxLength": 255,
                "description": "The name the recipient sees on a document, where the destination shows one. Defaults to the uploaded file's name."
              }
            },
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1,
      "maxItems": 1,
      "description": "One image, video, audio file, or document, with `text` as its caption (up to 1,024 characters; audio takes none). Staged, then fetched by WhatsApp from a URL Koil signs."
    },
    "target": {
      "type": "object",
      "required": [
        "kind",
        "externalId"
      ],
      "properties": {
        "kind": {
          "enum": [
            "whatsapp.groups.messages"
          ]
        },
        "externalId": {
          "type": "string",
          "description": "Platform-owned content identifier.",
          "minLength": 1
        }
      },
      "additionalProperties": false,
      "description": "One thing on the platform outside this item: content, an account, or anything else the platform gives an id or a URL."
    },
    "previewUrl": {
      "type": "boolean",
      "description": "Render a link preview for the first URL in the text."
    }
  },
  "additionalProperties": false,
  "anyOf": [
    {
      "required": [
        "text"
      ]
    },
    {
      "required": [
        "attachments"
      ]
    }
  ]
}
```

#### Media requirements

An asset that meets everything under _Copied as is_ is published exactly as uploaded. Otherwise Koil converts only what misses, a billed media add-on that needs a paid plan. Anything under _Refused_ fails the publish request, since no conversion fixes it.

| Media | Copied as is | Otherwise converted | Refused |
| --- | --- | --- | --- |
| Image | JPEG or PNG | re-encoded to JPEG | over 5 MB once staged |
| Video | MP4/MOV, H.264 | re-encoded to H.264 in MP4 | over 16 MB once staged |
| Audio | AAC, AMR, MP3, M4A or Ogg | — | any other format; over 16 MB |
| Document | PDF, DOC, DOCX, XLS, XLSX, PPT or PPTX | — | any other format; over 100 MB |

### `perform_action`

Mark a message a participant sent as read, showing them a read receipt. Unlike in a 1:1 chat, WhatsApp marks only that message, not those before it.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes | The participant's message, as its `externalId` names it (a `wamid`), from a `created` event. |
| `action` | `"seen"` | yes | What to do with the item: `seen` (show the person a read receipt for their messages). |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId",
    "action"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The participant's message, as its `externalId` names it (a `wamid`), from a `created` event."
    },
    "action": {
      "enum": [
        "seen"
      ],
      "description": "What to do with the item: `seen` (show the person a read receipt for their messages).",
      "x-koil-narrows": "ContentAction"
    }
  },
  "additionalProperties": false
}
```

### Not offered

-   `list`: platform no endpoint
-   `get`: platform no endpoint
-   `update`: platform not supported
-   `delete`: platform not supported
-   `perform_action` `typing_on`: platform not supported — WhatsApp shows a typing indicator in 1:1 chats only; in a group it only marks a message read.
-   `perform_action` `typing_off`: platform not supported — WhatsApp shows a typing indicator in 1:1 chats only; in a group it only marks a message read.

### Events

-   [`content.whatsapp.groups.messages.created`](https://docs.koil.co/events#content.whatsapp.groups.messages.created)

Backfill: not offered — platform no endpoint.

Item schema

What `list` and `get` return and what events carry as `data`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `containerId` | `string` | yes | The conversation: the same on every message in it, on reads and events alike, so an inbox groups by it. It is TikTok's conversation id, a WhatsApp group's id, and in a 1:1 chat on Instagram, Facebook or WhatsApp the counterpart's own id, since Meta's messaging webhooks carry no conversation id. |
| `target` | `object` | no | The one thing on the platform this item directly responds to: a comment's post, or the comment it replies to; a message's quoted or replied-to message, story or comment; what a reaction reacts to. Absent when the platform reports nothing it responds to. |
| `references` | `object[]` | no |  |
| `text` | `string` | no | Caption/body text for content. |
| `author` | `object` | yes | Platform actor reference for observed content. |
| `ownerAuthored` | `boolean` | no | Whether the Profile's own account wrote it. Absent when Koil cannot tell, which does not mean someone else did. |
| `attachments` | `unknown \| unknown \| unknown[]` | no |  |
| `choice` | `object` | no | The option the person picked instead of typing: a quick reply, a button or a list row a message offered, or one of the account's ice breakers. Its label is the message's `text`, and the message that offered it is `target` where the platform names it. Present where the platform reports the tap, which on Instagram and Messenger is the message's event only: a read of the same message returns its `text` without `choice`. Absent too when the platform withholds the payload (Meta sends a postback's payload only to the app that sent the button), so such a tap reads as typed text. |
| `publishedAt` | `string (date-time)` | no | When the platform published it. |
| `externalId` | `string` | yes | Platform-owned content identifier. |
| `variant` | `"text" \| "image" \| "video" \| "audio" \| "document" \| "sticker" \| "location" \| "contacts" \| "interactive" \| "button" \| "referral" \| "order" \| "system" \| "unsupported" \| "other"` | yes | The Cloud API message `type`. Media types carry one `attachments` entry; `location` carries `location`; `unsupported` is a type the Cloud API cannot deliver (e.g. a poll); `other` is a type Meta added that Koil does not model yet. |
| `authorPhoneNumber` | `string` | no | The person's phone number in E.164 digits, present only when Meta shares it: when the business messaged or called that number, or was messaged or called from it, in the last 30 days, or has it in its contacts. Never a key: it can be absent on one message and present on the next, so identify the person by their BSUID. |
| `location` | `object` | no | Geographic place reference for content. |
| `platformRaw` | `unknown` | no | Optional platform-native payload included only for transient delivery/debug use. |
| `kind` | `"whatsapp.groups.messages"` | yes | The collection that delivered this item. |

## `whatsapp.groups.statuses`

Delivery and read statuses of messages the number sent to groups, per participant (`recipient`) where Meta names one. Events only.

### Not offered

-   `list`: platform no endpoint
-   `get`: not applicable
-   `resolve_attachment`: not applicable
-   `publish`: not applicable
-   `update`: not applicable
-   `perform_action`: not applicable
-   `delete`: not applicable

### Events

-   [`content.whatsapp.groups.statuses.created`](https://docs.koil.co/events#content.whatsapp.groups.statuses.created)

Backfill: not offered — platform no endpoint.

Item schema

What `list` and `get` return and what events carry as `data`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `externalId` | `string` | yes | Platform-owned content identifier. |
| `containerId` | `string` | yes | The group the message this status reports on went to, as the group's messages name it. |
| `target` | `object` | yes | The outbound message this status reports on, by the `externalId` its publish request returned. |
| `status` | `"sent" \| "delivered" \| "read" \| "played" \| "failed" \| "other"` | yes | The delivery state this status reports. `other` is a state Meta added that Koil does not model yet. |
| `recipient` | `object` | no | Platform actor reference for observed content. |
| `occurredAt` | `string (date-time)` | no |  |
| `conversation` | `object` | no |  |
| `pricing` | `object` | no |  |
| `errors` | `object[]` | no |  |
| `callbackData` | `string` | no |  |
| `platformRaw` | `unknown` | no | Optional platform-native payload included only for transient delivery/debug use. |
| `kind` | `"whatsapp.groups.statuses"` | yes | The collection that delivered this item. |

## `whatsapp.groups.conversations`

The WhatsApp groups the business number is in, each keyed by the group id its messages carry as `containerId`. An event carries only the fields its change states: a create's subject and join approval mode, an applied subject or description, a suspension, or no field when people join or leave. Meta opens groups only to Official Business Accounts.

### `list`

List the groups the business number is in now, with each group's subject and creation time. A group the number has left or deleted is not listed; `get` reads the rest of a group.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `cursor` | `string` | no | Opaque cursor for fetching the next result page. |
| `limit` | `integer` | no | Maximum number of items to return. |
| `includePlatformRaw` | `boolean` | no | Whether to include transient platform-native payloads. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "cursor": {
      "type": "string",
      "description": "Opaque cursor for fetching the next result page.",
      "minLength": 1
    },
    "limit": {
      "type": "integer",
      "description": "Maximum number of items to return.",
      "minimum": 1,
      "maximum": 100
    },
    "includePlatformRaw": {
      "type": "boolean",
      "description": "Whether to include transient platform-native payloads."
    }
  },
  "additionalProperties": false
}
```

### `get`

Get one WhatsApp group by its id: its subject, description, settings and participants, each keyed by BSUID.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes |  |
| `includePlatformRaw` | `boolean` | no | Whether to include transient platform-native payloads. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1
    },
    "includePlatformRaw": {
      "type": "boolean",
      "description": "Whether to include transient platform-native payloads."
    }
  },
  "additionalProperties": false
}
```

### `update`

Change a WhatsApp group's subject or description, answering with the group as read right after. Meta reports each change's outcome later, as an `updated` event carrying the fields it applied, so the answer may not show a change Meta has yet to apply.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes | The group's id, as its `externalId` names it. |
| `subject` | `string` | no | The group's new name. |
| `description` | `string` | no | The group's new description. |
| `includePlatformRaw` | `boolean` | no | Whether to include transient platform-native payloads. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The group's id, as its `externalId` names it."
    },
    "subject": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "description": "The group's new name."
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2048,
      "description": "The group's new description."
    },
    "includePlatformRaw": {
      "type": "boolean",
      "description": "Whether to include transient platform-native payloads."
    }
  },
  "additionalProperties": false,
  "anyOf": [
    {
      "required": [
        "subject"
      ]
    },
    {
      "required": [
        "description"
      ]
    }
  ]
}
```

### `delete`

Delete a WhatsApp group, removing every participant, the business included.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `profileId` | `string` | yes | Koil Profile associated with the operation. |
| `externalId` | `string` | yes | The group's id, as its `externalId` names it. |

JSON Schema

```json
{
  "type": "object",
  "required": [
    "profileId",
    "externalId"
  ],
  "properties": {
    "profileId": {
      "type": "string",
      "description": "Koil Profile associated with the operation.",
      "minLength": 1
    },
    "externalId": {
      "type": "string",
      "minLength": 1,
      "description": "The group's id, as its `externalId` names it."
    }
  },
  "additionalProperties": false
}
```

### Not offered

-   `resolve_attachment`: not applicable
-   `publish`: not implemented — Meta creates a group asynchronously: the create answers with a request id only, and the group's id and invite link arrive later on a `group_lifecycle_update` webhook, which Koil emits as `created` but cannot route back to the publish that asked for it, so a publish could not answer with the group it made.
-   `perform_action`: platform not supported

### Events

-   [`content.whatsapp.groups.conversations.created`](https://docs.koil.co/events#content.whatsapp.groups.conversations.created)
-   [`content.whatsapp.groups.conversations.updated`](https://docs.koil.co/events#content.whatsapp.groups.conversations.updated)
-   [`content.whatsapp.groups.conversations.deleted`](https://docs.koil.co/events#content.whatsapp.groups.conversations.deleted)

Backfill: supported (partial coverage); see [Backfill history](https://docs.koil.co/guides/backfill).

Item schema

What `list` and `get` return and what events carry as `data`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `counterpart` | `object` | no | The person the account is talking to in a 1:1 conversation. A group chat has none. |
| `messageRequest` | `boolean` | no | Whether the conversation is still a message request: the person wrote and the account has not replied yet. Absent when the read or event did not say. |
| `updatedAt` | `string (date-time)` | no | When the conversation last changed, as the platform reports it. |
| `externalId` | `string` | yes | The group's id: the `containerId` its messages carry, which a group send takes. |
| `subject` | `string` | no | The group's name. |
| `description` | `string` | no | The group's description. Read by `get`; an event carries it only when it changed. |
| `participants` | `object[]` | no | The people in the group, not counting the business, each keyed by BSUID as a group message's `author` is. Read by `get` only. |
| `participantCount` | `integer` | no | How many people are in the group, not counting the business. Read by `get` only. |
| `joinApprovalMode` | `"approval_required" \| "auto_approve" \| "other"` | no | Whether a person who opens the group's invite link needs the business's approval to join (`approval_required`) or joins at once (`auto_approve`). Read by `get`, and carried by the `created` event. |
| `suspended` | `boolean` | no | Whether WhatsApp has suspended the group, which stops activity in it. Read by `get`, and carried by the `updated` event of a suspension or its lifting. |
| `createdAt` | `string (date-time)` | no | When the group was created. |
| `platformRaw` | `unknown` | no | Optional platform-native payload included only for transient delivery/debug use. |
| `kind` | `"whatsapp.groups.conversations"` | yes | The collection that delivered this item. |
