API reference

Assistant: Chat and conversations

Talk to your personal assistant from your own program exactly as in the app's chat window: the same assistant, tools, memory and approvals, and each answered turn counts against your plan as in the app. Send a message and get the reply (or poll for it), follow the turn's steps, stop a turn, and list, search, read and erase your conversations with the assistant - chats and calls on every channel. 9 endpoints. Add your API key in the authentication panel to send test requests from this page.

Read a chat's messages

GET/api/external/v1/assistant/chat/{conversationId}/messages

The messages of one of your chats with the assistant in the app, oldest first, as the app's chat window shows them: yours (role CUSTOMER), the assistant's (ASSISTANT: its answers, the words it wrote while working, visuals and cards in metadata) and tool lines (SYSTEM, or ASSISTANT with metadata.isToolStatus). Each has id, role, content, messageType, visibility, metadata, clientMessageId and createdAt.

With after (a message id, or an ISO-8601 time): the messages after it, at most limit - for polling and catching up; hasMore says more follow, and nextAfter is the cursor for the next call. Without it: the newest limit messages, oldest first (earlierLeftOut says earlier ones were left out). limit is 1-100, default 50. conversation says whether the chat still takes messages (open).

Errors: 400 INVALID_ID, INVALID_CURSOR; 404 CONVERSATION_NOT_FOUND.

Parameters

  • conversationIdstringpathRequired

    The conversation's id.

  • afterstringquery

    Only messages after this one: a message id, or an ISO-8601 time.

  • limitinteger (int32)query

    At most this many messages: 1-100, default 50.

Responses

  • 200OK

Wait for the answer to a message

GET/api/external/v1/assistant/chat/{conversationId}/messages/{messageId}/reply

The answer to one of your messages in a chat (the message.id of a send that answered 202), waiting for it as the send does: up to waitSeconds (0-60, default 30). 200 once the turn has ended, 202 while the assistant still works. The body is the send's: status, conversation, message, messages (everything after it), reply, turn and poll.

Errors: 400 INVALID_ID; 404 CONVERSATION_NOT_FOUND, MESSAGE_NOT_FOUND (no message of yours with this id in the conversation).

Parameters

  • conversationIdstringpathRequired

    The conversation's id.

  • messageIdstringpathRequired

    The id of your message, as the send answered it.

  • waitSecondsinteger (int32)query

    How long to wait for the answer: 0-60 seconds, default 30.

Responses

  • 200OK

See what the running turn does

GET/api/external/v1/assistant/chat/{conversationId}/turn

What the assistant's turn in one of your chats does right now - or did moments ago - as the app's chat window shows it while the assistant works: startedAtMs, finishedAtMs (null while it runs), steps (getting ready, searching knowledge, each tool with tool, label, status RUNNING/DONE/FAILED, detail and the web sources it found, what you wrote that it read meanwhile, a stop) and refs (the things of yours it opened, changed or created). 204 when no turn ran there in the last minutes.

Errors: 400 INVALID_ID; 404 CONVERSATION_NOT_FOUND.

Parameters

  • conversationIdstringpathRequired

    The conversation's id.

Responses

  • 200OK

Stop the running turn

POST/api/external/v1/assistant/chat/{conversationId}/turn/stop

Asks the assistant's turn running in one of your chats to stop, as the Stop button in the app does: it ends at its next step (a tool that already runs is let finish) on a "[Stopped]" line, which is never charged. Answers stopping (true when a turn was running and is asked to stop) and turnStartedAtMs (which turn, as GET .../turn names it; null when none ran).

Errors: 400 INVALID_ID; 404 CONVERSATION_NOT_FOUND.

Parameters

  • conversationIdstringpathRequired

    The conversation's id.

Responses

  • 200OK

Send a message to your assistant

POST/api/external/v1/assistant/chat/messages

Says something to your assistant exactly as if you typed it in the app's chat window, and waits for the answer. The turn runs in your own chat with the assistant: the same assistant, tools, memory and approvals as in the app. Anything that would reach other people (an email, a message, a booking, a call) waits for your approval as it does in the app; the reply then carries the approval card the app shows (in the message's metadata, e.g. kiApproval), to be decided in the app or through the approvals API. Each answered turn counts against your plan like a turn in the app.

Body fields:

  • message (required): what you say, at most 16000 characters.
  • conversationId: the conversation to write in, from an earlier answer. Left out: your current chat with the assistant in the app is continued - the one the app's window shows now - or a new one begins when none is open. Chats end after a while without messages; then leave it out to go on.
  • newConversation (default false, only without conversationId): end the current chat and begin a new one, as the window's "New chat".
  • offTheRecord (default false, only without conversationId): write in your off-the-record chat instead - a conversation of its own of which the assistant keeps nothing, that is in none of your lists, and whose messages are deleted once it ends. It is continued while it is open; end it with POST /assistant/chat/off-the-record/end.
  • waitSeconds (0-60, default 30): how long to wait for the answer. 0 answers at once.
  • clientMessageId (at most 120 characters): your own id for the message. Sent again in the same conversation, the message is not taken twice: the answer is the first one's.

Answers 200 when the turn ended within the wait, 202 when the assistant still works (then poll poll.reply, which waits again, or poll.turn and poll.messages). The body: status (ANSWERED, STOPPED, NO_REPLY - the turn ended without words - or WORKING), conversation (id, status, open, offTheRecord, startedAt, lastActivityAt, endedAt), message (yours as kept), messages (everything written after it, oldest first: the words the assistant wrote while working, visuals, cards and its answer, each with id, role CUSTOMER/ASSISTANT/SYSTEM, content, messageType, metadata, createdAt), reply (the answer among them, or null), turn (the turn's steps as the app shows them: startedAtMs, finishedAtMs, steps with kind PREPARE/KNOWLEDGE/TOOL/HEARD/STOP, tool, label, status, detail, sources, and refs: the things of yours it touched) and poll.

Errors: 400 MISSING_FIELD, MESSAGE_TOO_LONG, INVALID_ID, CONFLICTING_FIELDS (conversationId with newConversation or offTheRecord), CLIENT_MESSAGE_ID_TOO_LONG; 404 CONVERSATION_NOT_FOUND; 409 TURN_RUNNING (a turn runs in the conversation: poll poll.turn, then send again), CONVERSATION_ENDED, CONVERSATION_NOT_OPEN (one of yours that takes no messages here), CALL_IN_PROGRESS (a call runs from this chat), DISABLED / HIDDEN (the assistant is not available to the account); 429 RATE_LIMITED (the chat's message limits per minute), APP_CHATS_USED_UP (today's chats with the assistant on your plan are used - the same as in the app: limit, power, nextPower, nextLimit and resetsAt, the next midnight in your time zone).

Request body application/json

  • messagestring
  • conversationIdstring
  • newConversationboolean
  • offTheRecordboolean
  • waitSecondsinteger (int32)
  • clientMessageIdstring

Responses

  • 200OK

End your off-the-record chat

POST/api/external/v1/assistant/chat/off-the-record/end

Goes back on the record, as switching off the record in the app's chat window does: your off-the-record chat with the assistant ends when one is open, and what was said in it is deleted. Your ordinary chat is left as it is. Answers ended: how many chats ended (0 or 1).

Responses

  • 200OK

List your conversations with the assistant

GET/api/external/v1/assistant/conversations

Your conversations with the assistant on every channel, newest first, as the assistant page lists them: chats in the app, calls, WhatsApp, SMS, email, Slack, Instagram, Messenger and Telegram. Off-the-record conversations and erased ones are never listed.

Each item: key (s:<chat id> or c:<call id>: use it to read or erase one), sessionId (a chat's id: the conversationId of the chat endpoints), callRowId, channel, startedAt, endedAt, live, title and summary (the assistant's note of it), messageCount, durationSeconds, actionCount (what the assistant did in it), reflection, callStatus, callResult; in a search also snippet and matchedIn (NOTE or MESSAGE).

query: only conversations whose note or what was said has these words. channel: one of APP, WEB_CALL, VOICE, WHATSAPP, SMS, EMAIL, SLACK, INSTAGRAM, MESSENGER, TELEGRAM. Paging: pass the answer's nextBefore as before for the next page (null at the end). limit is 1-50, default 20.

Errors: 400 INVALID_CHANNEL, INVALID_TIME.

Parameters

  • querystringquery

    Only conversations whose note or messages have these words.

  • channelstringquery

    Only this channel: APP, WEB_CALL, VOICE, WHATSAPP, SMS, EMAIL, SLACK, INSTAGRAM, MESSENGER or TELEGRAM.

  • beforestringquery

    Only conversations begun before this ISO-8601 time: the previous page's nextBefore.

  • limitinteger (int32)query

    At most this many: 1-50, default 20.

Responses

  • 200OK

Read one conversation

GET/api/external/v1/assistant/conversations/{key}

One of your conversations with the assistant in full, as the assistant page shows it: the list item's fields, then transcript (its last 400 lines, oldest first: at, role PERSON/AGENT/OTHER/SYSTEM, text, and what came with a line - visual, work, approval, reaction, card ...), truncated (earlier lines were left out), actions (what the assistant did in it, worded in lang), tasks (the agenda items it produced) and callRecordingAvailable.

key is s:<chat id> or c:<call id> from the list. Errors: 404 CONVERSATION_NOT_FOUND.

Parameters

  • keystringpathRequired

    The conversation's key: s:<chat id> or c:<call id>.

  • langstringquery

    The language of the actions' words (en, de, tr, ...); default: your app's.

Responses

  • 200OK

Erase a conversation from memory

DELETE/api/external/v1/assistant/conversations/{key}

Erases one of your conversations from the assistant's memory and from your lists, as the assistant page does: the conversation is hidden from you, the assistant's note of it is forgotten, and the journal pages of its days are taken out, so no later conversation starts knowing it. 204 when done.

key is s:<chat id> or c:<call id> from the list. Errors: 404 CONVERSATION_NOT_FOUND (not yours, or erased already).

Parameters

  • keystringpathRequired

    The conversation's key: s:<chat id> or c:<call id>.

Responses

  • 200OK