Skip to the documentation
API

Chats

Every operation in this group: what it accepts, what it returns and the errors it can answer with.

Operations

The conversations held with the assistant in the app, as the assistant panel lists them. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

GET/chats

List the assistant chats

Scopesthreads:readReads

Your chats, newest first, a page at a time, each with its title, how many messages it holds and when it last changed. q searches the titles and sort orders them. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:read scope.

Query parameters

qstring

Search the titles.

Up to 200 characters
sortstring

newest and oldest order by the last change, and title alphabetically.

One of"newest""oldest""title"Default"newest"
limitinteger

Rows per page, 1 to 100.

At least 1At most 100Default25
cursorstring

The previous page's nextCursor, passed back as it came. It is opaque: it holds where the last row sat in this list's order, so a row deleted or edited between pages never breaks the walk, and the next page starts at the first row that sorts after it. A value this list did not hand out is a 400 invalid_cursor.

Returns

A page of chats.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
chats.list()chats.listAll()chats.iterate()
Python
chats.list()chats.list_all()chats.iterate()
Ruby
chats.listchats.list_allchats.iterate
PHP
chats->listchats->listAllchats->iterate
Go
Chats.ListChats.ListAllChats.Iterate
Java
chats().listchats().listAllchats().iterate
C#
Chats.ListAsyncChats.ListAllAsyncChats.IterateAsync
MCP
listChats

GET/chats/{id}

Retrieve a chat

Scopesthreads:readReads

One chat by id. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:read scope.

Path parameters

idstringRequired

The chat id from GET /chats.

Returns

200Chat

The chat.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
chats.get()
Python
chats.get()
Ruby
chats.get
PHP
chats->get
Go
Chats.Get
Java
chats().get
C#
Chats.GetAsync
MCP
getChat

PATCH/chats/{id}

Rename a chat

Scopesthreads:writeChanges data

Gives the chat a new title. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:write scope.

Path parameters

idstringRequired

The chat id from GET /chats.

Request body

titlestringRequired
1 to 120 characters

Returns

200Chat

The chat with its new title.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
chats.rename()
Python
chats.rename()
Ruby
chats.rename
PHP
chats->rename
Go
Chats.Rename
Java
chats().rename
C#
Chats.RenameAsync
MCP
renameChat

DELETE/chats/{id}

Delete a chat

Scopesthreads:writeDeletes

Deletes the chat and every message in it, for good. Nothing it did in the mailbox is undone. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:write scope.

Path parameters

idstringRequired

The chat id from GET /chats.

Returns

Deleted.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
chats.delete()
Python
chats.delete()
Ruby
chats.delete
PHP
chats->delete
Go
Chats.Delete
Java
chats().delete
C#
Chats.DeleteAsync
MCP
deleteChat

GET/chats/{id}/messages

List the messages of a chat

Scopesthreads:readReads

The messages of one chat, a page at a time, from the first unless order is desc: what was said, the tools the assistant called with their results, and the files that came with them. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:read scope.

Path parameters

idstringRequired

The chat, as GET /chats lists it.

Query parameters

limitinteger

Rows per page, 1 to 50.

At least 1At most 50Default20
cursorstring

The previous page's nextCursor, passed back as it came. It is opaque: it holds where the last row sat in this list's order, so a row deleted or edited between pages never breaks the walk, and the next page starts at the first row that sorts after it. A value this list did not hand out is a 400 invalid_cursor.

orderstring

asc reads the chat from its first message, and desc from its newest.

One of"asc""desc"Default"asc"

Returns

A page of messages.

Errors

400

invalid_cursor: the cursor does not come from this list, or the chat changed under it. Start again without one.

The errors every operation can return401403404422429500Error catalog

Also available in

TypeScript
chats.listMessages()chats.listAllMessages()chats.iterateMessages()
Python
chats.list_messages()chats.list_all_messages()chats.iterate_messages()
Ruby
chats.list_messageschats.list_all_messageschats.iterate_messages
PHP
chats->listMessageschats->listAllMessageschats->iterateMessages
Go
Chats.ListMessagesChats.ListAllMessagesChats.IterateMessages
Java
chats().listMessageschats().listAllMessageschats().iterateMessages
C#
Chats.ListMessagesAsyncChats.ListAllMessagesAsyncChats.IterateMessagesAsync
MCP
approveChatToolCalldenyChatToolCalllistChatMessagessendChatMessagestopChatTurn

POST/chats/{id}/messages

Send a message to the assistant

Scopesthreads:writeChanges data

Says something in the chat and answers once the assistant has replied. An id that names no chat yet starts one. With regenerate, the assistant answers your last message again. The assistant answers in the same chat the app shows, with the tools the call's scopes reach. A tool that asks for a verification code is never offered, and a tool that changes something waits for an answer: the turn ends with status awaiting_approval and names the call in pendingToolCalls, and POST /chats/{id}/tool-calls/{toolCallId}/approve or POST /chats/{id}/tool-calls/{toolCallId}/deny answers it. A call you asked for in so many words runs without waiting, as it does in the app. The answer comes back once the turn has ended, so give this call a long timeout. A turn runs for at most 240 seconds. Past that it stops with stopReason time_limit and keeps what it had written. One turn runs in a chat at a time. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:write scope.

Path parameters

idstringRequired

The chat, as GET /chats lists it, or a new id of at most 64 characters to start one.

Request body

contentstring

What you say to the assistant. Required unless regenerate is true.

1 to 32000 characters
regenerateboolean

Answer your last message again instead of sending a new one. The reply it had is replaced.

messageIdstring

An id for your message, unique in this chat. Left out, one is made up.

1 to 64 characters
attachmentsobject[]

Up to 4 files for the assistant to read: { "fileId": id } for a file in Files, or { "filename", "content", "contentType" } for a text file of at most 256 KiB, its content in base64.

Up to 4 items
fileIdstringRequired
1 to 128 characters
threadIdstring

A conversation the chat is about. It is pinned to the chat with its first message, and the assistant reads it before it answers.

1 to 255 characters
templateIdstring

A template the assistant should work on, as the template editor of the app passes it.

1 to 128 characters

Returns

The turn, once it has ended.

Errors

404

resource_not_found: no such chat, an id that belongs to a task run, regenerate in a chat with no message from you, or, on an answer, no tool call with that id waiting for one.

409

chat_busy: the assistant is still answering in this chat. approval_pending: a tool call waits for an answer, so a new message cannot follow it. ai_not_configured: AI is unavailable on this server.

422

capability_unsupported: the key or app is limited to some addresses or domains. invalid_parameter: the body did not validate, or messageId is already in the chat.

429

ai_quota_exceeded: the workspace has used all of the AI actions its plan includes today, so nothing was saved.

rate_limited: the workspace's keys and apps together made more requests in 60 seconds than its limit, 1,000 on Starter, 5,000 on Pro and 10,000 on Max, unless the workspace has a limit of its own. Wait for the seconds in Retry-After. A request refused this way is not billed. Answered requests are billed at the apiRequests rate of the plan while pay as you go is on. Per 1,000,000 requests that is $0.50 on Starter, $0.30 on Pro and $0.20 on Max.

503

assistant_unavailable: the assistant could not be reached, so nothing was sent.

The errors every operation can return400401403500Error catalog

Also available in

TypeScript
chats.sendMessage()
Python
chats.send_message()
Ruby
chats.send_message
PHP
chats->sendMessage
Go
Chats.SendMessage
Java
chats().sendMessage
C#
Chats.SendMessageAsync
MCP
approveChatToolCalldenyChatToolCalllistChatMessagessendChatMessagestopChatTurn

POST/chats/{id}/stop

Stop the turn running in a chat

Scopesthreads:writeChanges data

Stops the assistant while it answers, in the app or through this API, and keeps what it had written. A tool call that had not returned is marked interrupted. Calling it when nothing runs is not an error: the answer is idle. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:write scope.

Path parameters

idstringRequired

The chat, as GET /chats lists it.

Request body

turnIdstring

Stops the turn only while it is this one, as turnId of a chat turn names it.

1 to 128 characters

Returns

What was running, now stopped, or idle.

Errors

503

assistant_unavailable: the assistant could not be reached, so nothing was stopped.

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
chats.stopTurn()
Python
chats.stop_turn()
Ruby
chats.stop_turn
PHP
chats->stopTurn
Go
Chats.StopTurn
Java
chats().stopTurn
C#
Chats.StopTurnAsync
MCP
approveChatToolCalldenyChatToolCalllistChatMessagessendChatMessagestopChatTurn

POST/chats/{id}/tool-calls/{toolCallId}/approve

Approve a tool call

Scopesthreads:writeSends mail

Lets the assistant run a call it asked to make, with the arguments the call shows and any args you send laid over them, and answers once the assistant has carried on. When the turn waits for several calls, it carries on once every one is answered. A call of a tool this key or app may not run in a chat, such as one asked for in the app that needs a scope the key does not hold, is refused with tool_not_offered before anything runs, and it keeps waiting. The answer comes back once the turn has ended, so give this call a long timeout. A turn runs for at most 240 seconds. Past that it stops with stopReason time_limit and keeps what it had written. One turn runs in a chat at a time. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:write scope.

Path parameters

idstringRequired

The chat, as GET /chats lists it.

toolCallIdstringRequired

The call, as pendingToolCalls of the last chat turn names it.

Request body

argsRecord<string, any>

Arguments to change before the call runs, laid over the ones the assistant chose. Left out, the call runs as asked.

Returns

The turn, once the assistant has carried on.

Errors

403

insufficient_scope: the key or app lacks threads:write. tool_not_offered: the call runs a tool this key or app may not use in a chat, because the tool needs a scope it does not hold or runs only in the app. Nothing ran, and the call still waits: deny it, or approve it in the app.

404

resource_not_found: no such chat, an id that belongs to a task run, regenerate in a chat with no message from you, or, on an answer, no tool call with that id waiting for one.

409

chat_busy: the assistant is still answering in this chat. approval_pending: a tool call waits for an answer, so a new message cannot follow it. ai_not_configured: AI is unavailable on this server.

422

capability_unsupported: the key or app is limited to some addresses or domains. invalid_parameter: the body did not validate, or messageId is already in the chat.

429

ai_quota_exceeded: the workspace has used all of the AI actions its plan includes today, so nothing was saved.

rate_limited: the workspace's keys and apps together made more requests in 60 seconds than its limit, 1,000 on Starter, 5,000 on Pro and 10,000 on Max, unless the workspace has a limit of its own. Wait for the seconds in Retry-After. A request refused this way is not billed. Answered requests are billed at the apiRequests rate of the plan while pay as you go is on. Per 1,000,000 requests that is $0.50 on Starter, $0.30 on Pro and $0.20 on Max.

503

assistant_unavailable: the assistant could not be reached, so nothing was sent.

The errors every operation can return400401500Error catalog

Also available in

TypeScript
chats.approveToolCall()
Python
chats.approve_tool_call()
Ruby
chats.approve_tool_call
PHP
chats->approveToolCall
Go
Chats.ApproveToolCall
Java
chats().approveToolCall
C#
Chats.ApproveToolCallAsync
MCP
approveChatToolCalldenyChatToolCalllistChatMessagessendChatMessagestopChatTurn

POST/chats/{id}/tool-calls/{toolCallId}/deny

Deny a tool call

Scopesthreads:writeChanges data

Refuses a call the assistant asked to make. The assistant is told, and carries on without it once every call it waits for is answered. Each person reaches only their own chats: an API key reaches the chats of the workspace owner, and an app reaches the chats of the person who connected it. A key or an app limited to particular addresses or domains is a 422 capability_unsupported.

Requires the threads:write scope.

Path parameters

idstringRequired

The chat, as GET /chats lists it.

toolCallIdstringRequired

The call, as pendingToolCalls of the last chat turn names it.

Returns

The turn, once the assistant has carried on.

Errors

404

resource_not_found: no such chat, an id that belongs to a task run, regenerate in a chat with no message from you, or, on an answer, no tool call with that id waiting for one.

409

chat_busy: the assistant is still answering in this chat. approval_pending: a tool call waits for an answer, so a new message cannot follow it. ai_not_configured: AI is unavailable on this server.

422

capability_unsupported: the key or app is limited to some addresses or domains. invalid_parameter: the body did not validate, or messageId is already in the chat.

429

ai_quota_exceeded: the workspace has used all of the AI actions its plan includes today, so nothing was saved.

rate_limited: the workspace's keys and apps together made more requests in 60 seconds than its limit, 1,000 on Starter, 5,000 on Pro and 10,000 on Max, unless the workspace has a limit of its own. Wait for the seconds in Retry-After. A request refused this way is not billed. Answered requests are billed at the apiRequests rate of the plan while pay as you go is on. Per 1,000,000 requests that is $0.50 on Starter, $0.30 on Pro and $0.20 on Max.

503

assistant_unavailable: the assistant could not be reached, so nothing was sent.

The errors every operation can return400401403500Error catalog

Also available in

TypeScript
chats.denyToolCall()
Python
chats.deny_tool_call()
Ruby
chats.deny_tool_call
PHP
chats->denyToolCall
Go
Chats.DenyToolCall
Java
chats().denyToolCall
C#
Chats.DenyToolCallAsync
MCP
approveChatToolCalldenyChatToolCalllistChatMessagessendChatMessagestopChatTurn

Objects

Chatobject

objectstringRequired
One of"chat"
idstringRequired
titlestringRequired
kindstringRequired
One of"chat"
messageCountintegerRequired
At least 0
updatedAtstringRequired

When a message last arrived in it.

Formatdate-time

ChatListobject

objectstring
One of"list"
dataChat[]
hasMoreboolean

True when another page follows. Pass nextCursor back as cursor to read it.

nextCursorstring

An opaque cursor for the next page, or null on the last page. Pass it back unchanged.

Can be null

ChatMessageobject

objectstringRequired
One of"chat_message"
idstringRequired

The message, unique in its chat.

chatIdstringRequired

The chat it belongs to.

positionintegerRequired

Where the message sits in the chat, counting from 0.

At least 0
rolestringRequired

user for what a person said, assistant for the replies.

One of"user""assistant"
createdAtstringRequired

When the message was written, when the chat knows.

Can be nullFormatdate-time
textstringRequired

The words of the message, without its calls or files.

partsChatMessagePart[]Required

The message in order: its words, the tools it called and the files it carries.

ChatMessageListobject

objectstring
One of"list"
hasMoreboolean

True when another page follows. Pass nextCursor back as cursor to read it.

nextCursorstring

An opaque cursor for the next page, or null on the last page. Pass it back unchanged.

Can be null

ChatMessagePartobject

typestringRequired

text carries text. tool_call carries toolCallId, toolName, args, result and status. file carries name, mediaType, url and fileId.

One of"text""tool_call""file"
textstring

The words.

toolCallIdstring

The call, as the approve and deny operations name it.

toolNamestring

The tool the assistant called.

argsany

What the assistant called the tool with.

resultany

What the tool answered. Null while it has not. When the key or app does not hold every scope the tool needs, it reads Redacted: this key or app may not read what this tool answered. instead. The answer of a tool that needs no scope reads the same for an app acting for a member: only a key, or an app the workspace owner connected, sees it. The tool, its arguments and its status stay.

statusstring

pending_approval while it waits for an answer, done once it ran, denied when it was refused, and interrupted when the turn stopped before it returned.

One of"pending_approval""done""denied""interrupted"
namestring

The file name.

mediaTypestring

The media type of the file.

urlstring

The file as a data URL, or null for a file kept in Files.

Can be null
fileIdstring

The file in Files, as GET /files/{id} reads it. Null for a file sent with the message.

Can be null

ChatPendingToolCallobject

toolCallIdstringRequired

The call, as the approve and deny operations name it.

toolNamestringRequired

The tool the assistant wants to call.

argsanyRequired

What it would call the tool with. Approve with args to change them.

ChatTurnobject

objectstringRequired
One of"chat_turn"
chatIdstringRequired

The chat the turn ran in.

turnIdstringRequired

The turn, as the stop operation can name it.

Can be null
statusstringRequired

completed when the assistant has answered. awaiting_approval when it waits for an answer to the calls in pendingToolCalls. stopped when it was stopped, keeping what it had written. failed when it could not finish, with error saying why.

One of"completed""awaiting_approval""stopped""failed"
stopReasonstringRequired

Why a stopped turn stopped: stop_requested when somebody stopped it, superseded when a new message in the app took its place, and time_limit when it ran too long. Null for every other status.

Can be nullOne of"stop_requested""superseded""time_limit"
messagesChatMessage[]Required

Your message and the replies to it, as the chat now holds them.

pendingToolCallsChatPendingToolCall[]Required

The calls the assistant waits for you to approve or deny. Empty unless status is awaiting_approval.

errorstringRequired

Why a failed turn failed. Null for every other status.

Can be null

ChatTurnStopobject

objectstringRequired
One of"chat_turn"
chatIdstringRequired

The chat.

turnIdstringRequired

The turn that stopped. For idle, the turnId you sent, or null.

Can be null
statusstringRequired

stopped when a turn was running and has stopped. idle when nothing was running, or another turn than turnId was.

One of"stopped""idle"

DeletedChatobject

objectstring
One of"chat"
idstring
deletedboolean
One oftrue