Messaging API
Receive every incoming customer message as a webhook, and send messages on any channel from your own app
Connect your own app (a helpdesk, a CRM, an agent console, an automation tool) to every customer conversation in your organization. The feature has two parts:
- Receive. We send a
message.receivedwebhook for every message a customer sends you, on every connected channel. - Send. You call
POST /messagesto reply on the same channel the customer used.
Your app does not need to know how Messenger, WhatsApp, Instagram or email work. One payload shape comes in and one request shape goes out, whatever the channel.
Customer ──► Messenger / WhatsApp / Instagram / Web / Mobile / Email
│
▼
Our platform ── message.received webhook ──► Your app
▲ │
└───────── POST /app/api/v1/messages ◄───┘All endpoints live under:
https://<your-domain>/app/api/v1<your-domain> is the domain you open the app on, as shown in your browser's address bar.
All request and response bodies are JSON.
Supported channels
platform | Channel | Receive | Send | channelId is | platformUserId is |
|---|---|---|---|---|---|
MESSENGER | Facebook Messenger | ✅ | ✅ | Your Facebook Page ID | The customer's Page-scoped ID (PSID) |
INSTAGRAM | Instagram Direct | ✅ | ✅ | Your Instagram account ID | The customer's Instagram-scoped ID |
WHATSAPP | WhatsApp Business | ✅ | ✅ | Your WhatsApp phone number ID | The customer's WhatsApp number, digits only |
WEB | Website chat widget | ✅ | ✅ | The widget ID | The visitor ID |
MOBILE | Mobile Chat API | ✅ | ✅ | The mobile app ID | Your endUserId |
EMAIL | Connected mailbox | ✅ | ✅ (replies only) | The connected mailbox ID | The customer's email address, lower-cased |
Two channels are not covered:
FACEBOOKcarries Page post comments. A comment is not a message.VOICEcarries phone calls. A call has no messages to send or receive.
1. Create an API key
The API uses the same organization API keys as the AI Agent Control API. Organization owners and admins can create them.
Settings › API Keys Open API Keys- Click New API key and enter a Name, such as the system that will use the key.
- Under Permissions, tick Send messages (
messages:send). A key only gets the permissions you tick, and a key without this one gets403fromPOST /messages. Keys created before this API existed do not have it, so create a new key. - Click Create key and copy the key.
It starts with
org_sk_and is shown only once. We store only a fingerprint of it, so we cannot show it to you again.
Keep the key on your server. Anyone who holds it can message any of your customers from any of your channels. The endpoint does not answer browsers (no CORS), so a key in a web page would not work anyway. Revoke a key from the same page if it may have leaked. It stops working immediately.
Send the key on every request:
Authorization: Bearer org_sk_…
Content-Type: application/json2. Receive messages: the message.received webhook
Settings › Webhooks
Open Webhooks
- Click Create Webhook.
- Enter a Name, put your endpoint in Webhook URL, and tick Message Received under Events.
The URL must be
httpsand must point at a public address: these deliveries carry your customers' messages. - Click Create Webhook. We generate the webhook's signing secret for you.
- Copy the secret with Copy Secret in the webhook list, or open the webhook and copy its Signing Secret. You will need it to verify signatures, and you can come back for it at any time.
From then on, every message a customer sends on any supported channel reaches your endpoint within a few seconds:
{
"event": "message.received",
"timestamp": "2026-10-07T09:14:03.250Z",
"data": {
"eventId": "5b0e7c1a-2f3d-8a8e-9c61-7d2e4f9a0b13",
"messageId": "msg_7Hq2kLm9",
"platformMessageId": "m_AbCdEf123456",
"conversationId": "conv_abc123",
"platform": "MESSENGER",
"channelId": "104857362918273",
"platformUserId": "7430219856123047",
"customerName": "John Doe",
"type": "TEXT",
"text": "Hi, where is my order?",
"attachments": [],
"interaction": null,
"referral": null,
"replyTo": null,
"email": null,
"botEnabled": true,
"ticketId": null,
"inboxUrl": "https://<your-domain>/app/inbox/all/conv_abc123",
"at": "2026-10-07T09:14:02.981Z"
}
}The Message Received event reference describes every field, the attachment shape and the email extras.
Things to know
- Customer messages only. Replies from the AI agent, from your team in the inbox, or from
your own
POST /messagescalls do not firemessage.received. Your app will not receive its own replies back, so you cannot create a loop by replying. - The AI agent keeps running. Receiving the webhook does not stop the AI agent from
answering. If your app's team should take over a conversation, switch the AI off for it
with the AI Agent Control API.
data.botEnabledtells you whether the AI is on for the conversation when the message arrived. - Deduplicate on
data.eventId. It is derived from the message, so it never changes for that message. Never deduplicate ontimestamp. - Route on
data.channelIdwhen your organization has several Pages, numbers or mailboxes. - Answer within 30 seconds with any
2xx, then do your processing. We do not follow redirects. - Failed deliveries are retried. Up to 6 attempts over about 7½ hours, carrying the same
data.eventId. See Retries and Idempotency. You can also resend a delivery by hand: open the webhook in Settings › Webhooks and go to its Logs tab. - Taps, reactions and ad clicks have their own events. Tick them on the same webhook if you
need them:
message.postbackfor Get Started, menu items and postback buttons,message.reaction,conversation.referralfor an ad or link click with no message, andmessage.readwhen the customer sees what you sent. A quick-reply tap is an ordinarymessage.receivedwhoseinteractiontells you which reply was tapped.
Verify the X-Webhook-Signature header on every delivery, as described in
Verify the signature.
3. Send a message
curl -sS -X POST "https://<your-domain>/app/api/v1/messages" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 0b8e2f6a-1c4d-4e7f-9a2b-3c5d6e7f8a9b" \
-d '{
"conversationId": "conv_abc123",
"message": { "type": "TEXT", "text": "Your order shipped this morning." }
}'{
"success": true,
"idempotent": false,
"conversationId": "conv_abc123",
"platform": "MESSENGER",
"messages": [
{
"messageId": "msg_9Xp4rTn2",
"platformMessageId": "m_GhIjKl789012",
"status": "SENT",
"createdAt": "2026-10-07T09:15:11.402Z"
}
]
}The message appears in the inbox like any other reply, marked with an API badge (or with
your actorLabel, if you send one).
Every response carries an X-Request-Id header. Include it when you contact support about a
call.
Choose the conversation
Name one conversation in one of two ways. Sending both forms, or neither, returns 400.
Our conversation ID. Use conversationId, taken from data.conversationId on the
webhook. This is the simplest option when you are replying to a message you received.
The IDs your system already has. Send all three of these fields:
{
"platform": "WHATSAPP",
"channelId": "112233445566778",
"platformUserId": "8801700000000",
"message": { "type": "TEXT", "text": "Hello!" }
}See Supported channels for what channelId and platformUserId
mean on each channel. When no conversation with that customer exists yet, you can start one
on WhatsApp with a template. On every other channel the call returns
404, because the customer has to message you first.
Request fields
| Field | Type | Required | What it does |
|---|---|---|---|
conversationId | string | One of the two forms | Our conversation ID. |
platform, channelId, platformUserId | strings | One of the two forms | All three together. |
message | object | Yes | What to send. See Message types. |
replyToMessageId | string | No | Our messageId of a message in the same conversation. On channels that support quoting (Messenger, Instagram, WhatsApp) the reply shows as a quote. On email it keeps the reply in that message's thread. Web and mobile ignore it. A message from a different conversation returns 400. |
actorLabel | string, ≤ 128 | No | Who on your side sent it, e.g. "agent@acme.com". It is shown in the inbox as the sender. |
Unknown fields return 400. They are never silently ignored.
Headers
| Header | Required | What it does |
|---|---|---|
Authorization | Yes | Bearer org_sk_… |
Content-Type | Yes | application/json, or multipart/form-data to upload files |
Idempotency-Key | Recommended | A unique string per message, 1–255 printable ASCII characters (a UUID is ideal). If you retry with the same key and the same body within 24 hours, we return the first result with "idempotent": true and do not send the message twice. The same key with a different body returns 422. |
A JSON body may be at most 256 KB, and a multipart/form-data body at most 10 MB.
4. Message types
Text
{ "type": "TEXT", "text": "Your order shipped this morning." }text is required, up to 4,096 characters. Longer text returns 400; we never cut it
silently.
Quick replies
Messenger and Instagram only. Up to 13 tappable replies shown under the text. Once the customer
taps one, they all disappear, and the tap reaches you as a message.received with the reply's
title as text and its payload in interaction.payload.
{
"type": "TEXT",
"text": "Which size do you need?",
"quickReplies": [
{ "title": "Small", "payload": "SIZE_S" },
{ "title": "Medium", "payload": "SIZE_M" }
]
}| Field | Type | Required | What it does |
|---|---|---|---|
quickReplies | array | No | 1–13 items. |
quickReplies[].title | string, 1–20 | Yes | What the customer sees and sends back. |
quickReplies[].payload | string, 1–1,000 | Yes | What comes back to you in interaction.payload. |
On any other channel quickReplies returns 400 UNSUPPORTED_FOR_CHANNEL. Instagram does not
show quick replies on desktop: a customer there sees only the text and can type an answer.
Buttons
Buttons under a short text: up to 3 on Messenger, Instagram and WhatsApp, and up to 10 on web chat.
A button either sends a payload back to you (postback) or opens a web page (web_url).
{
"type": "BUTTONS",
"text": "Your order is ready. What would you like to do?",
"buttons": [
{ "type": "postback", "title": "Track order", "payload": "TRACK_ORD-2026-001" },
{ "type": "web_url", "title": "View receipt", "url": "https://acme.com/r/ORD-2026-001" }
]
}| Field | Type | Required | What it does |
|---|---|---|---|
text | string, 1–640 | Yes | The text above the buttons. |
buttons | array | Yes | 1–3 buttons, or 1–10 on WEB. More than 3 on any other channel returns 400 UNSUPPORTED_FOR_CHANNEL. |
buttons[].type | string | Yes | postback or web_url. |
buttons[].title | string, 1–20 | Yes | The button label. |
buttons[].payload | string, 1–1,000 | For postback | What comes back to you when it is tapped. |
buttons[].url | string | For web_url | An https URL, up to 2,048 characters. |
platform | Sent as | A postback tap reaches you as |
|---|---|---|
MESSENGER | A button template | message.postback with your payload |
INSTAGRAM | A button template. Instagram's web version may not show it | message.postback with your payload |
WHATSAPP | Interactive reply buttons. postback only: a web_url button returns 400. Each payload is at most 256 characters, and payloads and titles must be unique within the message | message.received with interaction.type: "button_reply" and your payload in interaction.payload |
WEB | Buttons under the text in the chat widget. A web_url button opens its link in a new tab. Postback buttons are disabled once the visitor sends anything after them | message.received with the button's title as text, interaction.type: "button_reply" and your payload in interaction.payload |
MOBILE, EMAIL | Not supported: 400 UNSUPPORTED_FOR_CHANNEL | — |
Buttons are a normal message for the messaging window and the rate limits: they count as one message.
Image, video, audio, file
{
"type": "IMAGE",
"attachments": [
{ "url": "https://cdn.acme.com/size-chart.jpg" },
{ "url": "https://cdn.acme.com/fabric.jpg" }
],
"text": "Here is the size chart"
}| Field | Type | Required | What it does |
|---|---|---|---|
type | string | Yes | IMAGE, VIDEO, AUDIO or FILE. One media type per call. |
attachments | array | Yes | 1–10 items, each with a url. They are sent in array order. |
attachments[].url | string | Yes | A public https URL on the default port (443). See How we fetch attachments. |
attachments[].fileName | string, ≤ 128 | No | The file name the customer sees. Used for FILE and email. |
text | string | No | A caption. It goes with the first attachment only. Where the channel has no caption (WhatsApp audio, Messenger, the website widget, mobile), it arrives as a separate text message right after. |
Where the channel can group several images into one message (Messenger, Instagram), we group
them. On email, every file goes in one email. Elsewhere each attachment is its own message.
Every message created is listed in the response's messages array.
platform | IMAGE | VIDEO | AUDIO | FILE | Max file size |
|---|---|---|---|---|---|
MESSENGER | ✅ | ✅ | ✅ | ✅ | 25 MB |
INSTAGRAM | ✅ | ✅ | ✅ | ✅ (PDF only) | 8 MB image, 25 MB other |
WHATSAPP | ✅ | ✅ | ✅ | ✅ | 5 MB image, 16 MB video and audio, 100 MB file |
WEB | ✅ | ✅ | ✅ | ✅ | 25 MB |
MOBILE | ✅ | ✅ | ✅ | ✅ | 25 MB |
EMAIL | ✅ | ✅ (as a file) | ✅ (as a file) | ✅ | 25 MB in total |
One call may download at most 100 MB in total (25 MB on email). A type the channel cannot
carry returns 400 with code: "UNSUPPORTED_FOR_CHANNEL".
How we fetch attachments
We download every file ourselves, store a copy, and send the channel our copy. We never pass your URL to the channel. The download must meet all of these rules:
httpson port 443, with no username or password in the URL.- The host must resolve to a public internet address. Private, loopback, link-local and other internal addresses are refused, and so is any host name that resolves to one.
- At most 3 redirects, and every hop must meet the same rules.
- The response must be
2xx, within 30 seconds, with aContent-Typethat matchestype:image/*(not SVG) forIMAGE,video/*forVIDEO,audio/*forAUDIO.FILEtakes any type except web pages and scripts. On Instagram,FILEtakesapplication/pdfonly. - The file must fit the size limit above. We stop downloading the moment it goes over.
A URL that breaks the first two rules returns 400. A file we could not download returns
422 MEDIA_FETCH_FAILED.
Upload the file instead of a URL
If the file is not at a public URL, send it in the request itself as multipart/form-data.
The fields are the request fields, flat, and each file is a file part:
curl -sS -X POST "https://<your-domain>/app/api/v1/messages" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: 6f1c9e2a-0b7d-4e3f-9a51-2c8d7e4b1a90" \
-F conversationId=conv_abc123 \
-F actorLabel=agent01 \
-F type=FILE \
-F "text=Please check the invoice" \
-F "file=@invoice.pdf;type=application/pdf"| Field | Required | What it does |
|---|---|---|
conversationId, or platform + channelId + platformUserId | Yes | The conversation, as in a JSON request. |
type | Yes | IMAGE, VIDEO, AUDIO or FILE. Text, buttons and templates are sent as JSON. |
file | Yes | The file. Repeat the field for up to 10 files, sent in order. The file name is what the customer sees. |
text | No | A caption, as in a JSON request. |
actorLabel, replyToMessageId | No | As in a JSON request. |
Any other field returns 400, as an unknown JSON field does.
- The whole request may be at most 10 MB. A larger file has to go by URL.
- Each file must match
typeand fit the channel's size limit, the same rules as a downloaded file. On Instagram,FILEtakes PDF only. - We check that the file's content matches its type.
A file sent as
application/octet-streamtakes the type its content shows. - An
Idempotency-Keyretry is recognized by the fields and the files' content, so you can rebuild the form for a retry.
A JSON request and a multipart request never match each other for the same Idempotency-Key: reusing a key across the two returns 422 IDEMPOTENCY_KEY_REUSED.
The file in the response
Each message in the response that carried a file has an attachment with our copy of it, whether you sent a URL or uploaded the file:
{
"messageId": "msg_4Fh8sKd1",
"platformMessageId": "m_abc",
"status": "SENT",
"createdAt": "2026-11-09T10:16:40.112Z",
"attachment": {
"url": "https://storage.googleapis.com/…/invoice.pdf",
"fileName": "invoice.pdf",
"mimeType": "application/pdf",
"size": 184233
}
}A message that carried several files, such as a group of images on Messenger or one email, has an attachments array of the same objects instead.
We delete our copies after 30 days. Keep your own copy of any file you need to show for longer.
WhatsApp template
WhatsApp only. Use this to message a customer outside the 24-hour window (see Messaging windows), or to start a new conversation.
{
"type": "TEMPLATE",
"template": {
"name": "order_update",
"languageCode": "en_US",
"components": [
{
"type": "body",
"parameters": [{ "type": "text", "text": "ORD-2026-001" }]
}
]
}
}name uses lowercase letters, digits and underscores. languageCode looks like en or
en_US. components uses Meta's own shape and is passed through unchanged. The template must
be approved for that WhatsApp number in Meta Business Manager.
To start a new conversation, name it with platform, channelId and platformUserId. The
number must be in international format, digits only (a leading + is accepted). Each
organization can start at most 100 new conversations per hour this way.
On EMAIL, text becomes the body of a reply in the existing thread. The subject is
Re: <original subject>. The API does not start new email threads. Video and audio are
attached as files.
5. Messaging windows
Meta lets a business message a customer freely only for 24 hours after the customer's last action: a message, a button tap, a reaction, or a click on your ad or m.me / ig.me link. We time it from the channel's own timestamp, not from when we received the event. After that:
platform | What you can send after 24 hours |
|---|---|
WHATSAPP | A TEMPLATE message only. |
MESSENGER, INSTAGRAM | Nothing, until the customer writes again. |
WEB, MOBILE, EMAIL | No window. You can always send. |
A send outside the window returns 422 with code: "OUTSIDE_WINDOW" before anything is sent.
The data.at of the latest message.received, message.postback, message.reaction or
conversation.referral tells you when the customer last acted.
6. Responses and errors
messages[].status is SENT once the channel has accepted the message. Delivery receipts are
not reported. To learn when the customer has seen it, subscribe to
message.read: its messageId matches the
messageId returned here (WhatsApp, Instagram), or its readUpTo covers it (Messenger). platformMessageId is null on the website widget and
mobile, which have no channel ID of their own.
When an attachment array is only partly sent, the call still returns 200. The messages
that went out are in messages, and the ones that did not are in failed:
{
"success": true,
"idempotent": false,
"conversationId": "conv_abc123",
"platform": "WHATSAPP",
"messages": [{ "messageId": "msg_1", "platformMessageId": "wamid.1", "status": "SENT", "createdAt": "…" }],
"failed": [{ "index": 1, "url": "https://cdn.acme.com/b.jpg", "code": "MEDIA_FETCH_FAILED", "error": "HTTP 404" }]
}When the channel refused an item, its failed entry also carries platformCode and
platformSubcode when the channel gave them, as on a 502.
failed[].index is the position in your attachments array, or among your file parts.
An uploaded file's entry has its fileName instead of a url.
Retrying with the same
Idempotency-Key does not resend the parts that already went out. To send the failed items
again, make a new call with a new key.
All errors share one shape:
{ "success": false, "code": "OUTSIDE_WINDOW", "error": "The 24-hour window for this conversation closed at 2026-10-06T09:14:02.000Z" }| Status | code | When |
|---|---|---|
400 | INVALID_REQUEST | Invalid JSON or form data; wrong Content-Type; an unknown field; both or neither ways of naming the conversation; a missing or oversized field; a bad Idempotency-Key; a replyToMessageId from another conversation; an attachment URL that is not public https; an uploaded file that is empty, of a type type does not take, or whose content does not match its type. |
400 | UNSUPPORTED_FOR_CHANNEL | The channel cannot carry this message type, e.g. TEMPLATE on Messenger, quickReplies on WhatsApp, or a web_url button on WhatsApp. |
401 | UNAUTHENTICATED | Missing, unknown or revoked key. |
403 | FORBIDDEN | The key does not have the messages:send permission. |
403 | CHANNEL_DISCONNECTED | The Page, number, widget, app or mailbox has lost its connection or been switched off. Reconnect it in the dashboard. |
404 | NOT_FOUND | No such conversation, channel or customer in your organization. |
409 | IN_FLIGHT | A request with the same Idempotency-Key is still being sent. Wait a few seconds, then retry. |
413 | PAYLOAD_TOO_LARGE | A JSON body is over 256 KB, a multipart body is over 10 MB, or an uploaded file is over the channel's size limit. |
422 | OUTSIDE_WINDOW | The 24-hour window is closed. See Messaging windows. |
422 | IDEMPOTENCY_KEY_REUSED | The same Idempotency-Key was used with a different body. |
422 | MEDIA_FETCH_FAILED | We could not download any of the attachments, the type did not match, or a file was too large. failed lists each one. |
429 | RATE_LIMITED | Too many requests, or the channel is limiting us. Wait for the number of seconds in the Retry-After header. |
502 | PLATFORM_ERROR | The channel refused the message. error holds the channel's message, platformCode its error code and platformSubcode its error subcode, each when it gave one. Meta's subcode is often the more specific of the two, e.g. why a send outside the window was refused. |
503 | STORE_UNAVAILABLE | A brief problem on our side. Retry with the same Idempotency-Key. |
500 | INTERNAL | Something went wrong on our side. Retry with the same Idempotency-Key. For up to 5 minutes that retry may return 409 while we make sure the first attempt did not go out. |
Rate limits
| Limit | Applies to |
|---|---|
| 300 requests per minute | Each API key, across every endpoint it calls |
| 600 requests per minute | Each organization, across all its API keys |
| 30 messages per minute | Each conversation, counted in messages the customer receives (see below) |
| 100 new conversations per hour | Each organization, for WhatsApp templates sent to new numbers. A template the channel refuses still counts |
How messages are counted. Text, templates and emails count as one message. For attachments, each message the customer receives counts once:
- Images grouped on Messenger or Instagram count as one message for each group.
- Elsewhere, each file counts as one message.
- A caption that arrives as its own text message (Messenger, Instagram, the website widget, mobile, WhatsApp audio) counts as one more.
A request that would go over the limit is refused as a whole, and costs nothing from the limit. Nothing in it is sent.
The channels also apply their own limits per Page or number. When a channel limits us, you get
429 with a Retry-After header, the same as for our own limits.
7. Typing indicator and seen
Show the customer that someone is typing, or mark their messages as seen, while your app prepares a reply.
curl -sS -X POST "https://<your-domain>/app/api/v1/messages/actions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{ "conversationId": "conv_abc123", "action": "typing_on" }'Name the conversation the same two ways as on send. action is one of:
action | Messenger, Instagram | Website widget | |
|---|---|---|---|
typing_on | Shows the typing indicator | Marks the customer's last message as read and shows the typing indicator | Shows the typing indicator for up to 60 seconds |
typing_off | Hides it | Does nothing: WhatsApp hides it by itself when you reply or after about 25 seconds | Hides it |
mark_seen | Marks the customer's messages as seen | Marks the customer's last message as read | Shows "Seen" under the visitor's messages |
- Success is
204with no body. - It needs the same
messages:sendpermission, and counts toward the per-key and per-organization request limits, but not the per-conversation message limit. - No
Idempotency-Keyis needed: repeating an action is harmless. - It works only inside the messaging window (
422 OUTSIDE_WINDOWotherwise). It works only on Messenger, Instagram, WhatsApp and the website widget (400 UNSUPPORTED_FOR_CHANNELotherwise). - The body may be at most 4 KB. Errors use the same shape and codes as send.
8. Security checklist
- Keep the key on your server. Give it only the permissions it needs, use one key per system, and revoke it the moment it may have leaked.
- Verify
X-Webhook-Signatureon every delivery before you trust it, using the raw request body. - Deduplicate on
data.eventId, and answer within 30 seconds. - Send an
Idempotency-Keywith every message, so a retry after a timeout cannot message the customer twice. - Treat
data.text,data.email.htmland attachment contents as untrusted customer input. Escape them before you show them, and never run them.
Putting it together
A helpdesk that handles customers from every channel in one place:
- A customer writes on WhatsApp. You receive
message.receivedwithplatform: "WHATSAPP"andbotEnabled: true. The AI agent is answering, so your helpdesk only logs the message. - The customer asks for a person. Our workflow switches the AI off, and you receive
conversation.bot_disabled. - Your helpdesk opens a ticket. The customer's next messages arrive as
message.receivedwithbotEnabled: false. - Your agent replies from the helpdesk. Your server calls
POST /messageswith theconversationIdandreplyToMessageIdfrom the webhook. - When the ticket is solved, your server switches the AI back on with
POST /conversation/bot { "enabled": true }.
The same steps work for Messenger, Instagram, the website widget, the mobile app and email.
Only data.platform changes.