Develop
Reference

XTM One chat API

Talk to an XTM One agent from your code over HTTP: send a message and read its answer as server-sent events, follow, stop, steer or approve a request, and know how every request ends.

XTM OneEnterprise EditionFor developers and platform engineers

The web interface of XTM One, its Office add-in and your own scripts talk to a conversation over HTTP. A message goes in a POST whose response streams the request back as server-sent events (SSE), and a second stream follows the rest of the conversation. This page is the reference of those routes, under /api/v1/web/chat. It covers how to sign in and open a conversation, what to send, and the frames you receive while an AI agent works. It also covers how to stop, steer or approve a request, and what you can count on when a request ends. The REST routes under /api/v1/chat/conversations, listed at the end, serve the same conversations without a stream.

The WebSocket is gone

From XTM One 1.261112.0, these routes replace the WebSocket of a conversation, /api/v1/chat/conversations/{conversation_id}/ws, and its close codes. XTM One 1.261112.0 maps each WebSocket message to its route.

YOUR SCRIPTXTM ONEFRAMESSign inPOST /api/v1/auth/loginSendPOST …/web/chat/messagesFollowGET …/conversations/{id}/eventsConversationOne request at a timeAgentTools, modelsProgressturn_started, status, streamEnddone, error or cancelled
  1. Sign in → Send: access_token
  2. Send → Conversation: {"content": …}
  3. Conversation → Agent: runs the request
  4. Agent → Progress: as it works
  5. Agent → End: once
  6. Progress → Send: SSE response
  7. Conversation → Follow: other requests
A script sends a message over HTTP and reads the frames of its request as server-sent events until it ends

Before you start

  • The Enterprise Edition, with AI on. Without them, the routes that start or feed a request answer 403: see Refusals and What each edition of XTM One brings.
  • A session token. POST /api/v1/auth/login with {"email": ..., "password": ...} returns it as access_token. When the account has two-factor authentication, the answer carries "mfa_required": true and an mfa_token instead, which only POST /api/v1/auth/mfa/verify accepts. When local sign-in is turned off for single sign-on, the route answers 403. Send the token on every request as Authorization: Bearer {access_token}. The routes under /api/v1/web refuse a personal API key or a platform token with a 403, The web chat needs a web session; the REST routes accept a personal API key, Authorization: Bearer fcp-....
  • A conversation you own. Only its owner sends to it, follows it, and stops, steers or approves its requests. A conversation shared with you can be opened and paged, read-only.

Every message, streamed or over REST, counts against a limit of 30 a minute per person, and one agent run against the person's quota.

Read a stream

Both streams are text/event-stream responses. Each event is one data: line that holds a JSON frame with a type, followed by a blank line:

data: {"type": "stream", "content": "The loader of ", "turn_id": "c41f0e8a2b7d4c96a3e15f8d0b7c2e49"}

: keepalive

Once a stream has started, it writes a : keepalive comment at most 15 seconds after the last thing it wrote, so that proxies keep it open: skip it. Skip any frame type you do not know, too.

Name your client with an X-Chat-Client-Id header on every route that sends or acts on a request, up to 128 printable characters. Pass the same value as client_id when you follow the conversation: your own requests are then never repeated there. XTM One replaces a missing or invalid value with a random one.

Refusals

A refusal is an HTTP error with a readable detail. Where a client may need to branch on it, a code sits beside it:

StatusBodyWhen
403{"detail": "...", "code": "terms_required"}The person has not accepted the terms of use yet: they sign in once in the interface to accept them. Every route
403{"detail": "...", "code": "chat_unavailable"}The deployment is in the Community Edition. Only the routes that start or feed a request: send, steer, approve, upload, and open a new conversation. Restoring a conversation stays open
403{"detail": {"code": "ai_disabled", "message": "..."}}An administrator switched AI off. The same routes as chat_unavailable
401detail.code is session_expiredThe session ended. Sign in again

Without chat, everything else keeps working: listing, reading, renaming and deleting conversations, the events stream, the pending approvals, stop and continue.

A stream still open when its session ends sends {"type": "session_expired", "reason": "lifetime"}, or "idle", and ends. XTM One checks the session every 15 seconds. On the mobile app, a stream still open when the app locks behind its PIN sends {"type": "app_locked"} and ends.

Open a conversation

POST /api/v1/web/chat/sessions with {"agent_slug": "night-shift-triage"}, or agent_id, creates a conversation and answers its conversation_id. Add workspace_id to file it into a workspace. Without an agent, the General Assistant answers it. An unknown slug answers 404, Agent not found.

With {"conversation_id": ...}, the same route restores that conversation instead; one you cannot read starts a new one. A restore answers:

FieldWhat it holds
messages, has_moreThe latest messages, oldest first; has_more is true when older ones exist
agent_id, agent_name, workspace_idThe conversation's agent and workspace. Without an agent, agent_name names who answers: the agent standing in for the General Assistant, or the General Assistant
is_processingtrue while a request runs
pending_approvalsThe tool calls a running request waits for you to approve, or null
interrupted_turnThe last request stopped before its answer, with started_at and interrupted_at, or null: see How a request ends

The other routes of a conversation:

RouteWhat it does
GET /api/v1/web/chat/agentsThe agents you can chat with: id, name, slug, icon, description, group, badges and disable_chat. The General Assistant comes first, unless an agent stands in for it
GET /api/v1/web/chat/sessionsYour conversations, as {"conversations": [...]}. limit from 1 to 200, 50 by default, offset, workspace_id, and scope=shared for those shared with you
GET /api/v1/web/chat/sessions/{conversation_id}/messagesThe messages older than the message before, as {"messages": [...], "has_more": ...}. limit up to 500, 50 by default
PATCH /api/v1/web/chat/sessions/{conversation_id}{"title": ...} renames the conversation, {"workspace_id": ...} files it into a workspace
DELETE /api/v1/web/chat/sessions/{conversation_id}Archives the conversation. Answers 204
DELETE /api/v1/web/chat/sessionsArchives every conversation GET /api/v1/web/chat/sessions lists. Answers 204
POST /api/v1/web/chat/uploadA multipart form with conversation_id and file: stores the file for the next message and answers {"file_ids": [...]}

Send a message

POST /api/v1/web/chat/messages sends a message and streams its request back:

curl -N https://xtm-one.grand-meridian.example/api/v1/web/chat/messages \
  -H "Authorization: Bearer $XTM_ONE_TOKEN" \
  -H "Content-Type: application/json" \
  -H "X-Chat-Client-Id: soc-siem-script" \
  -d '{"conversation_id": "9a7f2e1d-4c3b-4e5a-8f6d-1b2c3d4e5f60", "content": "Summarize the alerts of FD-PAR-03 since 22:00"}'
FieldWhat it holds
conversation_idThe conversation, which must be yours
contentThe message
file_idsFiles stored beforehand with POST /api/v1/web/chat/upload
mentioned_agent_idsAgents that answer after the conversation's agent, in order: see Mention several agents
referenced_conversation_idsOther conversations the agent reads: see Reference other conversations
supports_tool_approvaltrue when your client answers approvals

A message refused before its request starts gets an HTTP error with {"detail": ...} instead of a stream:

StatusWhy
400The message is empty, or it adds a tool, knowledge base or integration you may not use
401The account may no longer chat, for example because it was deactivated
404Conversation not found: no such conversation of yours
409The conversation does not take a message from here: a group channel thread, or a request a channel message runs
422The Deep Investigation choices could not be read
429Too many messages: Retry-After says when to send again. A platform set to fail closed answers 503 while its rate limiter cannot be reached

That is why the status and headers of the response arrive with its first frame past thinking: nothing is written before them, not even a keepalive. Once the request has started, a failure is an error frame.

The response ends once the request, and the new title of the conversation if any, is delivered. Closing it early does not stop the request, nor does reading nothing for about 10 seconds, after which XTM One ends the response. The request runs on and stores its answer.

Frames

typeMeaning
thinkingYour message was received. It comes before the request runs
turn_startedYour message started a request of its own; turn_id names it. A message folded into a running request receives folded_into_active_turn instead: see Messages folded into a running request
statusProgress: status names the step, such as preparing, tool_start, thinking_text or streaming. wait_start announces a pause of the agent
streamThe next piece of the answer as it is written, in content
doneThe answer: content, and message_id, the stored assistant message. With "intermediate": true, it is a part of the answer already delivered while the agent keeps working: the request is not over
agentic_actionThe request was charged actions agentic actions, counted in the quota period it names
approval_requiredThe request waits for you to approve tool calls, in proposals. approval_resolved says the wait is over
conversation_titleThe conversation was given a title, in title
errorThe request ended without an answer; content says why
cancelledThe request was stopped

Every frame of the request carries its turn_id, thinking included; conversation_title belongs to no request and carries none. An error or cancelled with "provisional": true ends the request, but its stored end follows on the same stream. That end is a done or cancelled with message_id, or an error when the reply could not be stored. Any other error or cancelled is the last frame of the request.

Stop, continue or steer a request

The other actions on a running request are POST routes with the same headers. Each takes {"conversation_id": ...}:

RouteWhat it does
/api/v1/web/chat/messages/cancelStops the request and the background work it started. Answers 202, {"status": "cancelled", "turn": ...}
/api/v1/web/chat/messages/skip-waitEnds the pause a wait_start status announced; the request carries on. Answers 202, {"status": "wait_skipped", "turn": ...}
/api/v1/web/chat/messages/steerAlso takes content and file_ids: stores the message and hands it to the running request, which reads it at its next step. Answers {"status": "steered", "turn_id": ...}

turn says where XTM One reached the request: local, remote on another server of the platform, or none when nothing ran. Add "awaiting_send": true to a stop sent while your own message is on its way: answered none, the stop is kept for about 30 seconds, and that request ends cancelled as soon as it starts. A stop or a skip answers 503 when the request runs on another server and the message broker of XTM One cannot be reached: nothing reached it, so try again.

A steered message that no request takes answers 409: none runs, it was stopped, or it ended on the way. Nothing is stored and the message does not count against the limit: send it as a new message. An empty message answers 400, and too many messages 429 with Retry-After. {"status": "stored", "turn_id": null} means that the message is stored but no request is known to have taken it. With "answered": false, no request took it and no reply answers it. Either way, it stays in the conversation and shapes the next request: do not send it again. A 503 means nothing was stored: try again.

Approve a tool call

An agent set to ask before some tools pauses on them when your message carried "supports_tool_approval": true. It sends approval_required, whose proposals each name a tool_call_id. Answer with POST /api/v1/web/chat/messages/approve:

{"conversation_id": "9a7f2e1d-4c3b-4e5a-8f6d-1b2c3d4e5f60", "decisions": [{"tool_call_id": "call_5b1e0c7d", "decision": "approve"}]}

decision is approve, approve_always or reject, with an optional rejection_reason. XTM One answers {"status": "accepted", "decided": 1}, with the number of decisions it applied. It answers 400 without any decision, 404 for an unknown conversation, and 409 when nothing waits for an approval.

After a restart of your client, GET /api/v1/web/chat/conversations/{conversation_id}/pending-approvals returns what still waits, as {"proposals": [...], "turn": "running"}, or "idle". It answers 503 when the message broker cannot say, rather than an idle that would drop a prompt the request still waits on.

Mention several agents

To have several agents answer one message, add their ids in the order they answer:

{"content": "@crisis-briefer @night-shift-triage what do we tell the crisis cell?", "mentioned_agent_ids": ["7c0e5d2a-1b7f-4a51-9c1e-2f4d8a6b3e90", "0f3b9a64-5d2c-4e8b-8a17-6c9e1d2f4a73"]}

The conversation's agent answers first, then each mentioned agent, in the same request: every frame carries the same turn_id. Each reply but the last arrives as a done with "intermediate": true, and a status frame with "status": "mention_answering", agent_name, position and total announces the next agent. Every reply of such a request carries answered_by, with agent_id, agent_name and, when the agent has one, agent_icon; the General Assistant's own replies carry none. A note written in place of an agent that did not answer carries "mention_failed": true. Over REST, the replies after the first are in mention_messages.

A request can become such a request without your mentioning anyone: a message folded into it from elsewhere may mention agents. To tell your agent's reply from theirs, compare answered_by.agent_id with the conversation's agent.

Reference other conversations

To have the agent read other conversations, add their ids, in the streamed message and over REST alike:

{"content": "@weekly-velvet-harbor-brief what did we decide there?", "referenced_conversation_ids": ["3e8d1c52-7a49-4f06-b2d1-9c5e0a7f6b18"]}

GET /api/v1/chat/conversation-references lists the conversations you can reference. Every word of q, separated by spaces, hyphens or underscores, must appear in the title; limit, from 1 to 20, defaults to 8, and exclude leaves one conversation out. Each entry has id, title, key (what the interface writes after @), updated_at, is_own and, for a conversation shared with you, owner_name.

XTM One keeps at most 5 references, only to conversations you can open, never the conversation the message is sent in. The stored user message lists them in conversation_refs, with conversation_id, title and key.

Requests you did not send

A conversation can be open in several places: another tab, another device, voice mode, a script, a background task that reports back. To see what the others do as it happens, follow the conversation:

GET /api/v1/web/chat/conversations/{conversation_id}/events?client_id=soc-siem-script

This stream receives every request of the conversation that your client did not send, so that each place shows the answer as it is written. It also receives user_message frames, a user message stored from another place in message, and conversation_title and approval_resolved frames. It ends after 15 minutes, or when your client reads nothing for about 10 seconds: open it again. Two fields tell the frames apart:

FieldWhereMeaning
relayedEvery frame of a request your client did not send, and user_message framestrue: the request was sent elsewhere. Frames of your own requests never carry it
turn_idEvery frame of a request, from turn_started or folded_into_active_turn to its endNames the request. Your frames and the copies other clients receive carry the same value. user_message, conversation_title and session_expired carry none

An events stream opened while a request runs first receives a thinking frame with "resumed": true. Then come the steps, the reasoning and the answer written so far, then the rest as it comes. A request your client sent is not repeated when it opens the stream again with the same client_id. A script that cares only about its own messages ignores every frame with relayed, except those of the request its message was folded into.

Messages folded into a running request

A conversation runs one request at a time. A message sent while another request runs is folded into it: that request takes your message into account, and you receive:

{"type": "folded_into_active_turn", "conversation_id": "9a7f2e1d-4c3b-4e5a-8f6d-1b2c3d4e5f60", "folded": true, "turn_id": "c41f0e8a2b7d4c96a3e15f8d0b7c2e49"}

The frames of that request then follow on the same response, with relayed and that turn_id, up to its end. The agents your message mentions answer in that request, after its own agents, or in the next one when it ends first. Rarely, the message waits for the next request instead: "folded": false, with a turn_id only when a request is running, which picks the message up. Over REST, the same cases answer HTTP 202 with "status": "folded_into_active_turn" or "status": "queued_for_next_turn".

How a request ends

Every request you are shown ends with a done, cancelled or error frame, also one sent elsewhere, and also when the message broker of XTM One was briefly lost or the process that ran the request stopped. When XTM One ends a request itself, the error frame carries a reason:

reasonMeaning
interruptedThe request stopped before its answer, during a restart of the server for example
lostThe request is over, but how it ended could not be delivered. Read the conversation to see what it stored

A request still running when a restart stops waiting for it stores an assistant message before that error: it says the request was interrupted and names the tool calls that completed, those still running and the last action completed. Read back, that message has "interrupted": true and the completed calls in tool_call_trace. The REST request that started it answers 503 with Retry-After: read the conversation before you send the message again.

When the restart was the platform's own, a rolling update or a recycled worker, XTM One resumes the request by itself, unless you sent another message or stopped it since. The events streams of the conversation then receive a turn_resuming frame, followed by the frames of the resumed request.

A request that ended before storing its answer, or whose agent failed, leaves its tool work to the next message of the conversation, for 24 hours: the agent receives the calls it made and their results, and continues instead of calling the same tools again.

On the stream that runs it, a stopped request can end with two cancelled frames: the acknowledgement, then, once the stop is stored, a second one with message_id. In the same way, a failed agent can end with an error without reason, then a done with message_id once its reply is stored. Either frame means the request is over; the second says what to read back.

If your script waits for an answer that does not come, read GET /api/v1/chat/conversations/{conversation_id}: is_processing is false once no request runs, and the messages hold the answer. XTM One guarantees the end frame; this check covers a network that drops frames on your side.

REST routes

RouteWhat it does
POST /api/v1/chat/conversationsCreates a conversation, answers 201. Body: agent_id, the agent that answers, title, workspace_id
GET /api/v1/chat/conversationsYour conversations
GET /api/v1/chat/conversations/{conversation_id}A conversation with its latest messages (limit) and is_processing
GET /api/v1/chat/conversations/{conversation_id}/messagesOlder messages, before the message before
POST /api/v1/chat/conversations/{conversation_id}/messagesSends a message and waits for the answer: user_message, assistant_message, mention_messages. The same fields as POST /api/v1/web/chat/messages, and it accepts a personal API key
POST /api/v1/chat/conversations/{conversation_id}/uploadUploads a file. With create_message=false, it only stores the file and returns its file_id for the next message
GET /api/v1/agentsThe agents you can use, with their id and name
ExampleAsk the night shift triage agent from a SOC script

Paul Garnier, SOC analyst on the night shift at Grand Meridian Hotels, wants the Night shift triage agent to summarize an alert from the script that already reads the SIEM. The script signs in with an account without two-factor authentication, kept in the environment as XTM_ONE_URL, XTM_ONE_EMAIL and XTM_ONE_PASSWORD, and prints the answer as it is written:

import json, os

import requests

BASE = os.environ["XTM_ONE_URL"]  # https://xtm-one.grand-meridian.example
token = requests.post(f"{BASE}/api/v1/auth/login", json={
    "email": os.environ["XTM_ONE_EMAIL"],
    "password": os.environ["XTM_ONE_PASSWORD"],
}).json()["access_token"]
headers = {"Authorization": f"Bearer {token}", "X-Chat-Client-Id": "soc-siem-script"}

session = requests.post(f"{BASE}/api/v1/web/chat/sessions", headers=headers,
                        json={"agent_slug": "night-shift-triage"})
session.raise_for_status()
conversation_id = session.json()["conversation_id"]


def ask(question: str) -> str:
    with requests.post(f"{BASE}/api/v1/web/chat/messages", headers=headers, stream=True,
                       timeout=(10, 60),
                       json={"conversation_id": conversation_id, "content": question}) as response:
        response.raise_for_status()  # refused before the request started
        for line in response.iter_lines(decode_unicode=True):
            if not line.startswith("data: "):
                continue  # blank lines and ": keepalive"
            frame = json.loads(line[len("data: "):])
            if frame["type"] == "stream":
                print(frame["content"], end="", flush=True)
            elif frame["type"] == "done" and not frame.get("intermediate"):
                return frame["message_id"]
            elif frame["type"] in ("error", "cancelled") and not frame.get("provisional"):
                raise RuntimeError(frame.get("content") or frame["type"])
    raise RuntimeError("The stream ended without an answer: read the conversation")


ask("PowerShell started from Outlook on FD-PAR-03 at 23:12. "
    "Is it linked to Velvet Harbor, and what should I check first?")

The read timeout of 60 seconds is well above the 15 seconds between keepalives. The script keeps the frames flagged relayed: on its own response, they belong to the request its message was folded into. The agent reads OpenCTI and OpenAEV as Paul, and the answer prints piece by piece: the loader of Velvet Harbor's January intrusion started the same way, with the checks to run on the workstation.

What's next

NextXTM One emergency stop API
Develop
Integrations, APIs, MCP and contributing.

Published

Overview