Conversations API
The messenger home, identify, conversations, messages, rich content and answers, read receipts, ratings and attachments.
AAgent44Updated 12 min read
On this page
- The objects
- Rich content
- Answers
- GET /v1/messenger
- POST /v1/identify
- GET /v1/conversations
- POST /v1/conversations
- GET /v1/conversations/{id}
- POST /v1/conversations/{id}/messages
- Sending without duplicates
- POST /v1/bot-scenarios/{id}/run
- POST /v1/conversations/{id}/read
- POST /v1/conversations/{id}/rating
- POST /v1/attachments
- GET /v1/attachments/{id}
Every request sends Authorization: Bearer a44_pub_…. Endpoints that act for a user also send X-A44-User-Id or X-A44-Anonymous-Id (see the API overview).
The objects#
Conversation
Field | Meaning |
|---|---|
| UUID. |
| The subject given when it was opened, or |
|
|
|
|
| Timestamps. |
| The latest message's text, shortened. |
|
|
|
|
| The user's rating, 1 to 5, or |
|
|
| Who is writing a reply right now: |
Merged conversations. Your team can merge two of a user's conversations into one. The conversation that was merged away then stands for the one it went into: every endpoint that takes its id reads and writes the merged conversation, and answers with the merged conversation's own id, so an app that still holds the old id keeps working. GET /v1/conversations lists only the merged conversation. Treat the id in a response as the conversation's id, and expect it to differ from the one you asked for after a merge.
Message
Field | Meaning |
|---|---|
| UUID. |
|
|
| The AI agent's or bot's name, or the teammate's first name; |
| The teammate's photo, or |
| Plain text, up to 10,000 characters. May contain line breaks. |
|
|
| For the AI agent's messages, the help articles it answered from: |
| Rich content (a question with buttons, a text box, cards…), or |
| For the user's own messages, the |
| Timestamp with microseconds. Use it as |
Internal notes your team writes are never returned, and neither are email conversations.
Label the AI agent's messages. People must be able to tell when they're talking to an AI (in the EU this is a legal duty under the AI Act). The AI agent's author_name is a name you chose, such as "Ana", which can read like a person's, so wherever your app shows a message with author: "agent", show an "AI" badge next to the name, or write the name as "Ana (AI assistant)". The web messenger and agent44's emails already do this; the conversation list's last_message_author tells you when the latest message was the agent's.
Rich content#
A message's content is an object with a type. Bots send it today (Bot scenarios); more senders may come. Ignore types you don't know: new ones can be added without notice, and body covers them.
{ "type": "text", "text": "Hello" }
{ "type": "file", "name": "invoice.pdf", "url": "https://…", "mime_type": "application/pdf" }
{ "type": "animation", "url": "https://…/a.gif", "mime_type": "image/gif" }
{ "type": "audio", "url": "https://…/a.mp3", "mime_type": "audio/mpeg", "duration": 75 }
{ "type": "picker", "id": "plan", "text": "Which plan?", "required": false,
"choices": [ { "value": "pro", "label": "Pro", "selected": false, "icon": "🚀" } ] }
{ "type": "field", "id": "order", "text": "Your order number?", "explain": "e.g. A-1234",
"required": true, "value": null }
{ "type": "carousel", "text": "Our plans",
"targets": [ { "title": "Pro", "description": "For teams", "image": "https://…",
"actions": [ { "label": "See", "url": "https://…" } ] } ] }Type | What to show |
|---|---|
|
|
| A link, a GIF or video ( |
|
|
|
|
| Cards to swipe through: |
Every URL is https. Texts are plain text: never render them as HTML. There are at most 10 choices, 10 cards and 3 links a card. required is passed on as set; agent44 doesn't enforce it.
Answers#
To answer a picker or a field, send the user's answer as their message, with the message that asked and the choice:
{ "body": "Pro", "reply_to": "<the picker message's id>", "choice": { "id": "plan", "value": "pro" } }bodyis what the user sees as their message: the choice'slabel, or the text they typed.choice.idis the picker's or field'sid;choice.valueis the chosen choice'svalue, or the typed text (up to 1,000 characters).With
reply_to, agent44 checks the message is in this conversation and asks that question, and that the value is one of the picker's choices and the question isn't answered yet. It then marks it answered (selected/value), so the next read shows it, and a running bot goes on from there. An answer that doesn't fit is a422with{ "error": "…" }, and nothing is sent.Without
reply_to(a question your app showed itself, which agent44 never saw), the choice is only stored with the message.Your team sees the answer in the inbox as "Answered plan: pro".
The bot's next messages aren't in the response: they arrive with your next poll (since).
GET /v1/messenger#
What to show before the user writes. No identity headers needed.
{
"name": "Akmi",
"logo_url": "https://app.agent44.ai/media/…?w=128",
"brand_color": "#2F6BFF",
"team": { "online": true, "reply_time": "minutes", "expected_reply": "The team usually replies in a few minutes." },
"ai_agent": { "name": "Akmi Assistant" },
"csat": true,
"messenger": { "greeting": "Hi there 👋", "intro": "Ask us anything. The team usually replies in a few minutes.", "position": "right", "show_help": true },
"help_center": { "name": "Akmi Help", "url": "https://akmi.agent44.ai/help-center", "ai_answers": true, "search_placeholder": "Search for answers" },
"idempotent_sends": true
}team.online follows your office hours (Settings › Inbox › General). reply_time is minutes, hour, hours or day, and expected_reply says it in words (or that the team is away). ai_agent is null when the AI agent is off, and help_center when there's no public or in-app help center. idempotent_sends is true when a message sent again with the same client_id is stored only once: retry a send by yourself only then (see Sending without duplicates).
POST /v1/identify#
Saves who the user is. Call it at launch and at sign-in.
{
"external_user_id": "usr_7f3a9c2e41",
"user_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"anonymous_id": "3f9c0a7e-5b1d-4c2a-9e8f-1a2b3c4d5e6f",
"email": "maya@example.com",
"name": "Maya",
"attributes": { "plan": "pro", "app_version": "4.2.0", "old_flag": null }
}Field | Rules |
|---|---|
| Your user id, up to 256 characters. |
| The user id's signature for identity verification (the |
| The device's anonymous id (8 to 64 characters of |
| Up to 320 characters. Not verified: see Identity and security. |
| Up to 200 characters. |
| An object, merged into the stored attributes; a |
Answers 204. With neither id, nothing is saved (it only marks the key as working). Attributes over 16,000 characters are a 413, and so is an update that would leave the user with more than 200 attribute keys or 64 KB of them: "Contact attributes are full (at most 200 keys and 64 KB). Remove some by sending them as null."
GET /v1/conversations#
The user's conversations, newest activity first, at most 50: { "conversations": [Conversation, …] }. An unknown user gets an empty list.
POST /v1/conversations#
Opens a conversation with a first message, creating the user if they're new.
{ "body": "Restore purchases does nothing.", "subject": "Purchases", "attachments": ["<id from POST /v1/attachments>"],
"client_id": "3f9c0a7e-5b1d-4c2a-9e8f-1a2b3c4d5e6f" }body: up to 10,000 characters (413over that). A body or at least one attachment is required.subject: optional, up to 200 characters.attachments: optional, up to 10 ids of files this same user uploaded.client_id: optional, a UUID your app makes for this first message. Sending the same request again answers200with the conversation it already opened, not a second one. See Sending without duplicates.
Answers 201 with { "conversation": Conversation, "messages": [Message] }. If the AI agent is on for this time of day, it starts answering. A user can open 10 conversations a day (429 past that).
It also takes a choice (see Answers), stored with the message. reply_to is a 422 here: a new conversation has no message to reply to.
GET /v1/conversations/{id}#
{ "conversation": Conversation, "messages": [Message, …], "has_more": false }, the latest 200 messages, oldest first. has_more is true when the page left messages out.
Parameter | Meaning |
|---|---|
| The |
| The |
| Page size, 1 to 200 (200 by default), with any of the above. |
Polling. Send the created_at of the newest message a GET returned, exactly as sent. Within a conversation, messages are timed in the order they're saved, so a poll never skips one that was still being saved when the previous poll ran, and a page that's full (has_more) never cuts between messages that share a time: poll again straight away. Move since only with what a GET returned, not with the message POST …/messages answers with: a reply saved between your last poll and your message is older than it. Your own message then comes back in the next poll, so keep messages by id and show each once.
How often. Every response, 200 or 304, has an X-A44-Poll-After header: how many seconds to wait before the next poll. It is 2 while the AI agent is answering a message the user just sent, 4 for two minutes after any message, 8 once the conversation has been quiet for two minutes, 15 after a quarter of an hour, and 30 when the conversation is closed. Use it in place of a fixed interval, clamped to a range you're comfortable with (the Flutter SDK uses 2 to 60 seconds), and fall back to your own interval when it's missing. Poll at once anyway when a push notification for the conversation arrives or the app comes back to the foreground, so a late reply isn't held back.
Sending since and before together, or a bad before, before_id or limit, is a 400. Send If-None-Match with the last ETag: an unchanged page is a 304. A conversation that isn't this user's is a 404.
After your team merges another conversation into this one, its messages appear in the thread at the times they were written, which are before your since. A poll doesn't return them: load the conversation without since (when the user opens it again, say) to get the whole thread.
POST /v1/conversations/{id}/messages#
{ "body": "It's an iPhone 15 on iOS 18.", "attachments": ["…"], "client_id": "8b1e6d2c-0f4a-4b7e-9c3d-5a6f7e8d9c0b" }Same rules as opening one. Answers 201 { "message": Message }. Writing in a closed conversation reopens it. A user can send 20 messages a minute (429 past that). Add reply_to and choice to answer a picker or field (see Answers).
Sending without duplicates#
Chat apps show a message the moment the user presses Send, then post it in the background. To do that safely, make a UUID for each message before you post it and send it as client_id, with POST /v1/conversations and POST /v1/conversations/{id}/messages alike.
Check
idempotent_sendsfirst.GET /v1/messengersays whether the server stores client ids. While it'sfalse(or missing), a repeat can send the message twice: show the failure and let the user decide to try again. agent44's own messengers retry by themselves only when it'strue.Retries are safe. If the answer never arrives (a timeout, the app going to the background, no signal), post the very same request again with the same
client_id. When the first attempt did go through, you get the stored message back with a200(or, forPOST /v1/conversations, the conversation it opened) and nothing is sent twice: no second message, no second AI reply, and it doesn't count against the user's limits again. A first attempt that didn't go through is simply sent, with a201.Match your own bubble. Every message you sent with a
client_idcomes back with it, from thePOSTand from everyGET. Show your pending bubble under that id and replace it when a message with the sameclient_idarrives, whichever comes first: thePOST's answer or a poll.One id, one message. A
client_idthat isn't a UUID is a422. One that already names a different message (another conversation's, or one that isn't this user's) is a409client_id was already used for another message: make a new id for every new message, and keep it only for retries of that message.Ids are compared without regard to case and returned in lowercase.
Without a
client_ideverything works as before, and a retry may send the message twice.
POST /v1/bot-scenarios/{id}/run#
Runs a bot scenario for the user. See Bot scenarios for the whole guide.
{ "conversation_id": "<optional>" }The body is optional. Answers 200 with { "conversation": Conversation, "messages": [Message, …], "has_more": false }, like GET /v1/conversations/{id}, with the bot's first messages. 404 {"error": "Bot not found"} for an unknown or switched-off bot, 404 for a conversation_id that isn't this user's, 409 when that conversation is already running a bot, 429 when a new conversation would pass the user's 10 a day.
POST /v1/conversations/{id}/read#
No body. The user has seen everything in the conversation: clears unread and stops the "you have a reply" email for what they've read. Answers 204. Sending a message counts as reading what came before it.
POST /v1/conversations/{id}/rating#
{ "rating": 5, "comment": "Fixed in two minutes." }rating is a whole number from 1 to 5; comment is optional (cut to 1,000 characters). Only for a closed conversation (409 while it's open) in a workspace that asks for ratings (409 otherwise). A later rating replaces the earlier one. Answers 204.
POST /v1/attachments#
Uploads one file before you send it in a message. Send multipart/form-data with a file field:
curl -X POST https://api.agent44.ai/v1/attachments \
-H "Authorization: Bearer a44_pub_YOUR_KEY" \
-H "X-A44-User-Id: usr_7f3a9c2e41" \
-F "file=@screenshot.png;type=image/png"Allowed | Rules |
|---|---|
Images | PNG, JPEG, WebP, GIF. The bytes must be a real, complete image. Apple's "optimized" PNGs from app bundles are refused. An image sent with the wrong image type is kept under its real one. |
Must start with a PDF header. | |
Text |
|
Up to 10 MB (413 over that). Another type is a 415; a damaged file is a 400 that says what's wrong. Answers 201 { "id", "name", "type", "size" }. Send the id in a message's attachments; only the same user can attach it.
GET /v1/attachments/{id}#
The file behind an attachment's signed url (?ws=&exp=&sig=). It needs no key or headers, so images can load directly. An expired or altered link is a 403. Images are served inline; PDFs and text files as downloads.