Chat API
Chat is your private, one-to-one conversation with an agent. You have one conversation with each agent, and it never ends: every message you send that agent goes into it, and you scroll up (or search) to find something earlier. Use these endpoints to send messages, wait for the agent’s answer and read the conversation, the same things you can do in the Chat view of the app. A conversation can’t be renamed, archived or deleted.
Whose chats a key reaches
A chat belongs to one person, and nobody else can read it. A key reaches the chats of the person it speaks for:
| Key | Reaches | Messages are written by |
|---|---|---|
| Your own key | Your chats | You |
| A service key you created (for example a script named “Weekly report”) | Your chats | The service, shown by name in the chat |
| An agent key, a key Cohort manages, or a key acting as another member | Nothing (403) | — |
Chats are also limited to the key’s workspace. An ID for anyone else’s chat, or a chat in another workspace, returns 404.
Scopes: reading requires chat:read; sending requires chat:write. full does not include either: a key reaches your chats only when it is granted chat:read / chat:write by name (on its own or alongside full), so an ordinary full-access key can never read or send into your private chats. Your workspace’s plan must include Chat.
Chat Object
{
"id": "chat_abc123",
"title": "Mara",
"status": "active",
"agent": {
"id": "agent_xyz",
"name": "mara",
"displayName": "Mara",
"title": "Chief of Staff",
"avatarUrl": "https://..."
},
"messageCount": 2,
"activeTurn": null,
"lastMessageAt": "2026-09-27T15:04:05.000Z",
"archivedAt": null,
"createdAt": "2026-09-27T15:00:00.000Z",
"updatedAt": "2026-09-27T15:04:05.000Z"
}| Field | Type | Description |
|---|---|---|
id | string | Chat ID: your conversation with this agent |
title | string | The agent’s name |
status | string | active |
agent | object | The agent this conversation is with |
messageCount | integer | Messages in the conversation |
activeTurn | object | null | { id, status, state } of the turn the agent is working on, or null |
lastMessageAt, createdAt, updatedAt | string | ISO 8601 |
archivedAt | string | null | Always null; conversations are not archived |
Message Object
{
"id": "msg_123",
"threadId": "chat_abc123",
"role": "human",
"body": "Plan my week",
"author": { "id": "user_1", "name": "sam", "displayName": "Sam", "type": "human" },
"clientMessageId": "7f1c2e9a-0d4b-4b5e-9a57-5b8f0c1d2e3f",
"turnId": "turn_456",
"suggestions": [],
"attachments": [
{ "fileId": "file_789", "fileName": "notes.txt", "mimeType": "text/plain", "size": 5 }
],
"earlierChatStartedAt": null,
"contextCompacted": false,
"createdAt": "2026-09-27T15:00:00.000Z"
}| Field | Type | Description |
|---|---|---|
role | string | human (your side) or assistant (the agent) |
author | object | { id, name, displayName, type }. type is human, service or agent |
clientMessageId | string | null | The idempotency key the message was sent with (human messages) |
turnId | string | null | The agent turn this message started (human messages). Null when it is waiting for a later turn (see Send a Message) or arrived at the daily text limit |
suggestions | array | { id, kind, text } next messages the agent suggested (assistant messages) |
attachments | array | Workspace files on the message. Download with GET /api/v1/files/:fileId/content |
earlierChatStartedAt | string | null | Set on the first message of an earlier chat that was merged into this conversation (from before each person had one conversation per agent): when that chat began. The app draws an “Earlier chat” divider above it |
contextCompacted | boolean | The agent summarized the conversation so far while answering this message (human messages). Nothing is removed; the app draws a divider before the reply |
Turn Object
Every message you send starts one turn: the agent’s work on an answer.
{
"id": "turn_456",
"threadId": "chat_abc123",
"status": "complete",
"state": "completed",
"errorCode": null,
"humanMessageId": "msg_123",
"replyMessageId": "msg_124",
"reply": { "id": "msg_124", "role": "assistant", "body": "Here's your week...", "author": { "type": "agent" } },
"createdAt": "2026-09-27T15:00:00.000Z",
"updatedAt": "2026-09-27T15:00:42.000Z",
"completedAt": "2026-09-27T15:00:42.000Z"
}status | Meaning |
|---|---|
pending | The agent hasn’t answered yet (state is queued, or running once it has picked the turn up). Keep waiting |
complete | reply holds the agent’s message |
failed | The agent couldn’t answer; see errorCode |
canceled | A newer message joined the conversation, and a new turn answers them together (errorCode is superseded) |
List Conversations
GET /api/v1/chatsYour conversations, one per agent you have written to, most recent first.
| Parameter | Type | Description |
|---|---|---|
status | string | active (default) or all |
limit | integer | Items per page (default 25, max 100) |
cursor | string | Cursor from the previous page |
curl "https://api.cohort.bot/api/v1/chats?limit=20" \
-H "Authorization: Bearer ch_live_your_key_here"{ "data": [ { "id": "chat_abc123", "title": "Mara", "status": "active" } ], "cursor": null, "hasMore": false }Send a Message to an Agent
POST /api/v1/chatsSends a message to an agent and queues the agent’s turn. The message goes into your one conversation with that agent; the first message you ever send it creates the conversation. Returns 201 with the conversation, the message and the turn.
| Field | Type | Required | Description |
|---|---|---|---|
agentId | string | Yes | The agent’s ID from GET /api/v1/agents |
body | string | Yes | The message, up to 20,000 characters. May be empty only when fileIds is not |
clientMessageId | string | No | Idempotency key (see below) |
fileIds | string[] | No | Up to 10 workspace files to attach, uploaded through the Files API |
curl -X POST https://api.cohort.bot/api/v1/chats \
-H "Authorization: Bearer ch_live_your_key_here" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7f1c2e9a-0d4b-4b5e-9a57-5b8f0c1d2e3f" \
-d '{ "agentId": "agent_xyz", "body": "Plan my week" }'{
"created": true,
"thread": { "id": "chat_abc123", "title": "Mara", "activeTurn": { "id": "turn_456", "status": "pending", "state": "queued" } },
"message": { "id": "msg_123", "role": "human", "body": "Plan my week", "turnId": "turn_456" },
"turn": { "id": "turn_456", "status": "pending", "state": "queued", "reply": null }
}Idempotency
Send an Idempotency-Key header, or clientMessageId in the body, to make a send safe to retry. Repeating the same key with the same payload returns the original chat, message and turn with 200 and the header Idempotent-Replayed: true, and nothing is sent twice. Reusing a key with a different payload returns 409. Without a key, every request sends a new message.
Get a Conversation
GET /api/v1/chats/:idReturns the conversation, including activeTurn while the agent is answering. The ID of an earlier chat that was merged into a conversation returns that conversation, so old links keep working.
Read Your Conversation with an Agent
GET /api/v1/chats/agents/:agent/messagesPages through your conversation with an agent by the agent’s ID or handle, without knowing the chat ID. Takes the same order, limit and cursor as List Messages. Before your first message to the agent, conversationId is null and data is empty.
curl "https://api.cohort.bot/api/v1/chats/agents/mara/messages?limit=50" \
-H "Authorization: Bearer ch_live_your_key_here"{ "conversationId": "chat_abc123", "agent": { "id": "agent_xyz", "name": "mara" }, "data": [ { "id": "msg_124", "role": "assistant" } ], "cursor": "...", "hasMore": true }List Messages
GET /api/v1/chats/:id/messages| Parameter | Type | Description |
|---|---|---|
order | string | desc (newest first, default) or asc (from the start) |
limit | integer | Items per page (default 25, max 100) |
cursor | string | Cursor from the previous page. Keep order the same while paging |
Continue until hasMore is false.
Send a Message
POST /api/v1/chats/:id/messagesSends a message to the conversation’s agent and queues its turn. Takes the same body as sending to an agent, without agentId. To send one of the agent’s suggestions, pass sourceMessageId (the assistant message) and sourceSuggestionId (the suggestion’s id) with body set to the suggestion’s text.
A conversation takes one turn at a time, and messages sent close together are answered together. The rule is the same on every channel: web, the iOS app, REST and iMessage.
- Sending while the agent is still answering joins the conversation. The open turn ends
canceledwitherrorCodesuperseded, and the new turn answers your earlier messages and this one together. - Many messages in quick succession. A turn answers only so many messages at once. Past that, your message waits, in order, for the next turn: the response’s
turnisnull, and the next turn starts when the open one ends. Nothing is dropped.
curl -X POST https://api.cohort.bot/api/v1/chats/chat_abc123/messages \
-H "Authorization: Bearer ch_live_your_key_here" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 2b7d9c1e-4f3a-4c8e-8d21-6a0f9e7b3c54" \
-d '{ "body": "Move the review to Thursday" }'Wait for the Answer
GET /api/v1/chats/:id/turns/:turnId?wait=25Returns the turn. While it is pending, wait (seconds, up to 25) holds the request open until the agent answers or the wait runs out, so you don’t need to poll. One waiting request counts once against your rate limit. If it comes back still pending, call it again.
curl "https://api.cohort.bot/api/v1/chats/chat_abc123/turns/turn_456?wait=25" \
-H "Authorization: Bearer ch_live_your_key_here"When status is complete, reply holds the agent’s message.
List a Chat’s Approvals
GET /api/v1/chats/:id/approvalsWhen an agent needs your OK before it acts, it asks in the chat. This returns those requests, newest first: the same approval cards the chat shows. canDecide is true while you can still answer one. To answer one, call POST /api/v1/approvals/:id/decision with { "decision": "approve" } or "deny", using your own key.
{ "data": [ { "id": "appr_123", "summary": "Send the draft to the vendor", "status": "pending", "chatThreadId": "chat_abc123", "canDecide": true } ] }Conversation Starters
GET /api/v1/chats/agents/:agent/starters
POST /api/v1/chats/agents/:agent/starters/:key/usedThe first lists the prompts you would see under a new chat with an agent, at most three, each with a key and its text. To use one, send its text as a message, then mark it used with the second call (URL-encode the key). A starter you have used is not offered to you for that agent again; marking one twice changes nothing.
{ "data": [ { "key": "files:document-to-task", "text": "Turn a document into a task." } ] }Your First Message
When you set up or join a workspace, its default agent writes to you first: your conversation with it already holds a short hello when you open Chat, and reading it here works the same way.