Documentation menu

Messages

Instagram direct messages and Facebook Page messages, normalized into one shape. Adeli refreshes history from the provider before returning it, at most once a minute per account; reads in between return what Adeli has stored, which incoming messages keep current as they arrive. Messages the account sends from the Instagram or Messenger app, or another tool, arrive the same way, as outbound.

Meta providers only

TikTok messaging is not supported, and YouTube has no messaging API at all — its direct messages were retired in 2019. WhatsApp sends free text inside its 24-hour window and approved templates outside it — see WhatsApp below.

Free text only inside a 24-hour window

Meta only permits a free-text reply within 24 hours of the person's last message, on Instagram, Facebook and WhatsApp alike. When Meta refuses a send because the window has closed, Adeli returns 409 window_closed; you cannot open one by sending first.

Endpoints

Conversations

Every message carries a conversationKey: <platform>:<counterparty id>, such as instagram:17841400000000001, facebook:6200000000000001 or whatsapp:15551234567 (the WhatsApp number as digits, without +). With the message's accountId it identifies one conversation. Pass both to List messages to read that conversation a page at a time, newest page first, following nextCursor toward older messages.

WhatsApp

Each profile can hold one WhatsApp number that the business connected itself, through Embedded Signup on the dashboard's Accounts page. It appears in GET /api/v1/accounts with platform: "whatsapp", the phone number ID as providerId, and the display number as displayIdentifier, and its history is included in GET /api/v1/messages. WhatsApp history is what Adeli has received by webhook and sent, so a read makes no provider call.

Through the API, WhatsApp sends free text inside the 24-hour window that opens when the customer writes, and one of the business's approved templates at any time — the only message WhatsApp allows when starting a conversation or more than 24 hours after the customer last wrote. A body carries text or template, never both (400 invalid_request).

json
{
  "platform": "whatsapp",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "recipient": "+15551234567",
  "text": "Your order is ready for pickup."
}

text is 1–4,096 characters. Outside the window, or to someone who has never written to the number, the response is 409 window_closed and nothing is sent; send a template instead. Success returns 201 with type: "text".

WhatsApp template body

platform"whatsapp"Required
accountIduuidRequired
The WhatsApp account in your organization.
profileIduuid
Optional, because accountId names its profile. If you pass both, they must agree.
recipientstringRequired
An E.164 phone number, such as +15551234567.
textstring
Free text, 1–4,096 characters, inside the 24-hour window only. Give text or template.
template.namestringRequired
An approved template on the business's WhatsApp Business Account: lowercase letters, digits, and underscores.
template.languagestringRequired
The template's language, such as en_US.
template.bodyParametersstring[]
Values for the body's {{1}}, {{2}}, … placeholders, in order. Up to 20; omit for a template without placeholders.
json
{
  "platform": "whatsapp",
  "accountId": "00000000-0000-0000-0000-000000000000",
  "recipient": "+15551234567",
  "template": { "name": "order_update", "language": "en_US", "bodyParameters": ["Jane", "A-42"] }
}

Success returns 201 with type: "template". A number whose setup has not finished returns 422 setup_incomplete; one whose access the business revoked returns 422 reconnect_required. An unknown or unapproved template fails at Meta and surfaces as 502 provider_error.

WhatsApp numbers cannot be connected through POST /api/v1/profiles/{profileId}/connect yet — that returns 422 provider_not_supported.

Instagram/Facebook inbox reads and sends, and WhatsApp sends, check their own messaging scope plus provider-confirmed Page task or WABA/phone binding before provider calls. A partial connection lacking that authorization returns 403 permission_required with the exact missing items and profile OAuth restart guidance. Existing stored conversation history is not reclassified as a broken connection.

Compatibility

Every existing request and response keeps working unchanged. Conversation reads, WhatsApp free text and the message.created webhook add new values to fields you may switch on:

  • POST /api/v1/messages takes a fourth body, WhatsApp text, so a client that handles every sendMessage body variant gains one.
  • Messages carry conversationKey, and GET /api/v1/messages responses filtered by it carry nextCursor. Unfiltered responses have no nextCursor.
  • Webhooks gain the message.created event type and the facebook and whatsapp values of platform. A receiver that switches exhaustively on type or platform should ignore, rather than reject, values it does not know.