Skip to content
Browse articles
API reference

Conversations API

The messenger home, identify, conversations, messages, rich content and answers, read receipts, ratings and attachments.

Agent44Updated 12 min read

On this page

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

id

UUID.

subject

The subject given when it was opened, or null.

status

open or closed. Writing in a closed conversation reopens it.

channel

sdk (opened from a native app's key) or web (a web app's key).

created_at, last_message_at

Timestamps.

last_message_preview

The latest message's text, shortened.

last_message_author

user, agent (the AI agent or a bot) or teammate.

unread

true when the team or AI agent wrote after the user last read it.

rating

The user's rating, 1 to 5, or null.

rating_requested

true when the conversation is closed, your workspace asks for ratings and the user hasn't rated it. Show the rating prompt then.

typing

Who is writing a reply right now: { "author": "agent", "name": "Ana" } while the AI agent works on an answer to the user's latest message, else null. Show a typing indicator with the name, labelled as AI like its messages. Read it from each poll; it goes back to null when the answer arrives, or after two minutes without one. More authors may come: show the name for any you don't know.

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

id

UUID.

author

user, agent or teammate. A bot's messages are agent too, with the bot's name. Label every agent message as AI where you show it (see below).

author_name

The AI agent's or bot's name, or the teammate's first name; null for the user.

author_avatar_url

The teammate's photo, or null.

body

Plain text, up to 10,000 characters. May contain line breaks.

attachments

[{ id, name, type, size, url }]. url is a signed link that works without headers and expires within two hours: fetch the conversation again for fresh ones.

sources

For the AI agent's messages, the help articles it answered from: [{ n, title, url }], cited in body as [n]. Empty otherwise.

content

Rich content (a question with buttons, a text box, cards…), or null. See Rich content below. body always holds its plain-text version, so a client that doesn't know content still shows something sensible.

client_id

For the user's own messages, the client_id your app sent with it, in lowercase; null when it sent none, and for everyone else's messages. See Sending without duplicates.

created_at

Timestamp with microseconds. Use it as since exactly as sent.

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

text

text (the same as body).

file, animation, audio

A link, a GIF or video (image/gif, image/webp, image/apng, video/mp4), or a player (duration in seconds).

picker

text as the question and a button per choice (label, with the optional icon emoji before it). Once answered, the chosen choice has "selected": true.

field

text as the question and a text box with explain as its placeholder. Once answered, value holds the answer.

carousel

Cards to swipe through: title, description, an optional image and up to 3 links (actions).

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" } }
  • body is what the user sees as their message: the choice's label, or the text they typed.

  • choice.id is the picker's or field's id; choice.value is the chosen choice's value, 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 a 422 with { "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

external_user_id

Your user id, up to 256 characters.

user_hash

The user id's signature for identity verification (the X-A44-User-Hash header works too; the body wins). Required with external_user_id when the key's workspace enforces it (new workspaces do): without a valid one the answer is 401 "This user couldn't be verified" and nothing is saved or merged.

anonymous_id

The device's anonymous id (8 to 64 characters of A–Z a–z 0–9 _ -). With external_user_id too, the anonymous user becomes the signed-in one, or their conversations, devices, segments and timeline events move to them.

email

Up to 320 characters. Not verified: see Identity and security.

name

Up to 200 characters.

attributes

An object, merged into the stored attributes; a null value removes that key. At most 16,000 characters of JSON in one request.

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 (413 over 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 answers 200 with 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

since

The created_at of the last message you have: only newer messages. Poll with this while the conversation is on screen. A since that isn't a full ISO timestamp is ignored.

before, before_id

The created_at and id of the oldest message you have: the page before it, for scrolling back. before must be an ISO timestamp and before_id a message id; before_id needs before.

limit

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_sends first. GET /v1/messenger says whether the server stores client ids. While it's false (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's true.

  • 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 a 200 (or, for POST /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 a 201.

  • Match your own bubble. Every message you sent with a client_id comes back with it, from the POST and from every GET. Show your pending bubble under that id and replace it when a message with the same client_id arrives, whichever comes first: the POST's answer or a poll.

  • One id, one message. A client_id that isn't a UUID is a 422. One that already names a different message (another conversation's, or one that isn't this user's) is a 409 client_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_id everything 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.

PDF

Must start with a PDF header.

Text

text/plain, UTF-8 only.

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.

Did this answer your question?