# WhatsApp Flows

Create, send and receive a form inside WhatsApp.

A Flow is a form that opens inside WhatsApp: booking an appointment, signing up, a survey, a quote request. The customer fills it in without leaving the conversation, and you receive their answers by [webhook](/en/docs/webhooks).

For Flows, the platform does three things: it creates and publishes the Flow at Meta, sends it in a conversation, and hosts the encrypted endpoint Meta calls when the form needs your data.

## Create and publish a Flow

`POST /flows` with:

- `connectionId`: the number that owns the Flow;
- `name` and `categories` (for example `["LEAD_GENERATION"]`);
- `flowJson`: the description of the screens, in Meta's Flow JSON format. Optional at creation;
- `cloneFlowId`: to start from an existing Flow;
- `endpointUri`: optional. By default the Flow points to the endpoint hosted by the platform.

The Flow starts as `DRAFT`. If the JSON has errors, the response lists them in `validationErrors`: fix them with `PATCH /flows/{id}` before publishing.

`POST /flows/{id}/publish` moves it to `PUBLISHED`. At Meta, a published Flow can no longer be edited: to change it, create a copy with `cloneFlowId`.

`GET /flows?connectionId=...` lists the Flows of a number, and `GET /flows/{id}` re-reads the state and validation errors at Meta.

## Send a Flow

A Flow is sent with `POST /messages` and the `flow` field. `flowId` accepts the platform's `flw_...` identifier or Meta's.

```json
{
  "connectionId": "con_...",
  "to": "+237600000000",
  "flow": {
    "mode": "data_exchange",
    "flowId": "flw_...",
    "body": "Book your slot in 30 seconds.",
    "button": "Book"
  }
}
```

Three modes, set by `flow.mode`:

| Mode | Use |
|---|---|
| `data_exchange` | Default. The Flow calls your server to load or validate data. `button` is required. |
| `navigate` | The Flow opens on the `screen` you give, with the `data` you provide, without calling your server. |
| `cta` | A message with a single button that opens the Flow. |

To test a Flow still in draft, add `"flowMode": "draft"`. The other optional fields are `header`, `headerImageUrl` and `footer`.

Like other free-form messages, a Flow can only be sent within the [24-hour window](/en/docs/messages).

## Receive the answers

When the customer finishes the form, you receive an inbound message in the `messages` webhook. Their answers are in `interactive.nfm_reply.response_json`, a JSON string to decode.

## Answer when the Flow calls your server

In `data_exchange` mode, Meta calls the platform's endpoint, which decrypts the request and forwards it to your server. Register your server's address with `POST /flow-endpoints`:

- `url`: an HTTPS address;
- `companyId` or `connectionId`: optional, to limit the address to one company or one number. Without them it covers the whole account.

When several addresses match, the most specific one wins: the connection, then the company, then the account. The `whsec_...` secret is returned only once, and the `X-Wa-Signature` signature is verified like the one on [webhooks](/en/docs/webhooks).

You receive:

```json
{
  "account_id": "acc_...", "company_id": "cmp_...", "connection_id": "con_...",
  "flow_id": "flw_...", "campaign_id": null, "recipient": "+237600000000",
  "payload": { "action": "data_exchange", "screen": "...", "data": { } }
}
```

Answer with JSON giving the next screen, in the shape Meta expects:

```json
{ "screen": "CONFIRMATION", "data": { "date": "2026-12-01" } }
```

> **Warning**

> Meta waits about ten seconds at most. Answer in under 8 seconds with a 2xx code. Otherwise, or if no address is registered, the customer sees the message "Service momentanément indisponible. Réessayez dans un instant." (in French, whatever the language of the Flow) on the current screen, provided that screen declares an `error_message` field.

## The Flow token

Every `data_exchange` or `cta` send carries a signed `flow_token` that the platform generates for you. It holds the number, the recipient and, when they exist, the Flow and the campaign, so you have nothing to store to recover the context. It is valid for 7 days, and an expired or forged token is refused.
