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
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
qstringSearch the titles.
Up to 200 characterssortstringnewestandoldestorder by the last change, andtitlealphabetically.One of"newest""oldest""title"Default"newest"limitintegerRows per page, 1 to 100.
At least 1At most 100Default25cursorstringThe 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 400invalid_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
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
idstringRequiredThe chat id from
GET /chats.
Returns
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
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
idstringRequiredThe chat id from
GET /chats.
Request body
titlestringRequired- 1 to 120 characters
Returns
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
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
idstringRequiredThe 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
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
idstringRequiredThe chat, as
GET /chatslists it.
Query parameters
limitintegerRows per page, 1 to 50.
At least 1At most 50Default20cursorstringThe 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 400invalid_cursor.orderstringascreads the chat from its first message, anddescfrom 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
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
idstringRequiredThe chat, as
GET /chatslists it, or a new id of at most 64 characters to start one.
Request body
contentstringWhat you say to the assistant. Required unless
regenerateis true.1 to 32000 charactersregeneratebooleanAnswer your last message again instead of sending a new one. The reply it had is replaced.
messageIdstringAn id for your message, unique in this chat. Left out, one is made up.
1 to 64 charactersattachmentsobject[]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 itemsfileIdstringRequired- 1 to 128 characters
threadIdstringA 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 characterstemplateIdstringA 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,regeneratein 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, ormessageIdis 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 inRetry-After. A request refused this way is not billed. Answered requests are billed at theapiRequestsrate 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
POST/chats/{id}/stop
Stop the turn running in a chat
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
idstringRequiredThe chat, as
GET /chatslists it.
Request body
turnIdstringStops the turn only while it is this one, as
turnIdof 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
POST/chats/{id}/tool-calls/{toolCallId}/approve
Approve a tool call
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
idstringRequiredThe chat, as
GET /chatslists it.toolCallIdstringRequiredThe call, as
pendingToolCallsof 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 lacksthreads: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,regeneratein 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, ormessageIdis 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 inRetry-After. A request refused this way is not billed. Answered requests are billed at theapiRequestsrate 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
POST/chats/{id}/tool-calls/{toolCallId}/deny
Deny a tool call
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
idstringRequiredThe chat, as
GET /chatslists it.toolCallIdstringRequiredThe call, as
pendingToolCallsof 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,regeneratein 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, ormessageIdis 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 inRetry-After. A request refused this way is not billed. Answered requests are billed at theapiRequestsrate 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
Objects
Chatobject
objectstringRequired- One of
"chat" idstringRequiredtitlestringRequiredkindstringRequired- One of
"chat" messageCountintegerRequired- At least 0
updatedAtstringRequiredWhen a message last arrived in it.
Formatdate-time
ChatListobject
objectstring- One of
"list" dataChat[]hasMorebooleanTrue when another page follows. Pass
nextCursorback ascursorto read it.nextCursorstringAn 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" idstringRequiredThe message, unique in its chat.
chatIdstringRequiredThe chat it belongs to.
positionintegerRequiredWhere the message sits in the chat, counting from 0.
At least 0rolestringRequireduserfor what a person said,assistantfor the replies.One of"user""assistant"createdAtstringRequiredWhen the message was written, when the chat knows.
Can be nullFormatdate-timetextstringRequiredThe words of the message, without its calls or files.
partsChatMessagePart[]RequiredThe message in order: its words, the tools it called and the files it carries.
ChatMessageListobject
objectstring- One of
"list" dataChatMessage[]hasMorebooleanTrue when another page follows. Pass
nextCursorback ascursorto read it.nextCursorstringAn opaque cursor for the next page, or null on the last page. Pass it back unchanged.
Can be null
ChatMessagePartobject
typestringRequiredtextcarriestext.tool_callcarriestoolCallId,toolName,args,resultandstatus.filecarriesname,mediaType,urlandfileId.One of"text""tool_call""file"textstringThe words.
toolCallIdstringThe call, as the approve and deny operations name it.
toolNamestringThe tool the assistant called.
argsanyWhat the assistant called the tool with.
resultanyWhat 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.statusstringpending_approvalwhile it waits for an answer,doneonce it ran,deniedwhen it was refused, andinterruptedwhen the turn stopped before it returned.One of"pending_approval""done""denied""interrupted"namestringThe file name.
mediaTypestringThe media type of the file.
urlstringThe file as a data URL, or null for a file kept in Files.
Can be nullfileIdstringThe file in Files, as
GET /files/{id}reads it. Null for a file sent with the message.Can be null
ChatPendingToolCallobject
toolCallIdstringRequiredThe call, as the approve and deny operations name it.
toolNamestringRequiredThe tool the assistant wants to call.
argsanyRequiredWhat it would call the tool with. Approve with
argsto change them.
ChatTurnobject
objectstringRequired- One of
"chat_turn" chatIdstringRequiredThe chat the turn ran in.
turnIdstringRequiredThe turn, as the stop operation can name it.
Can be nullstatusstringRequiredcompletedwhen the assistant has answered.awaiting_approvalwhen it waits for an answer to the calls inpendingToolCalls.stoppedwhen it was stopped, keeping what it had written.failedwhen it could not finish, witherrorsaying why.One of"completed""awaiting_approval""stopped""failed"stopReasonstringRequiredWhy a
stoppedturn stopped:stop_requestedwhen somebody stopped it,supersededwhen a new message in the app took its place, andtime_limitwhen it ran too long. Null for every other status.Can be nullOne of"stop_requested""superseded""time_limit"messagesChatMessage[]RequiredYour message and the replies to it, as the chat now holds them.
pendingToolCallsChatPendingToolCall[]RequiredThe calls the assistant waits for you to approve or deny. Empty unless
statusisawaiting_approval.errorstringRequiredWhy a
failedturn failed. Null for every other status.Can be null
ChatTurnStopobject
objectstringRequired- One of
"chat_turn" chatIdstringRequiredThe chat.
turnIdstringRequiredThe turn that stopped. For
idle, theturnIdyou sent, or null.Can be nullstatusstringRequiredstoppedwhen a turn was running and has stopped.idlewhen nothing was running, or another turn thanturnIdwas.One of"stopped""idle"
DeletedChatobject
objectstring- One of
"chat" idstringdeletedboolean- One of
true