Skip to content

AIChatSendMessage

POST ai/chat/message

Queues a question and returns at once with a runId. It does not wait for the model — an answer takes tens of seconds and the platform closes a call after five, so the interface shows an indicator and then either listens to events or polls AIChatGetRun.

Access Control

Allowed: client, manager, admin. Only inside a conversation of the current session.

Request

POST request
POST https://{broker_domain}/ai/chat/message
Authorization: <JWT_TOKEN>
Content-Type: application/json

{
  "conversationId": "cnv_8f3a…",
  "content": "Why was position 500103 closed?",
  "requestId": "b1f0-4c2e-…",
  "route": "/backoffice/trades"
}
{
  "command": "AIChatSendMessage",
  "extID": "1",
  "data": {
    "conversationId": "cnv_8f3a…",
    "content": "Why was position 500103 closed?",
    "requestId": "b1f0-4c2e-…"
  }
}
const run = await platform.AIChatSendMessage({
  conversationId, content: 'Why was position 500103 closed?', requestId
});

Parameters

Parameter Type Description
conversationId string Conversation to ask in
content string The question, 1 to 8000 characters
requestId string Optional but recommended, up to 128 characters. See below
route string Optional. The current interface screen, for example /backoffice/groups
accountLogin int Account context. Required for a client session of an account owner
symbol string Optional. The instrument the user is looking at

requestId is generated by the interface. Repeating it returns the existing run with idempotent: true instead of paying for a second answer — protection against a double click, a network retry and a page reload during send.

route improves the answer. A knowledge document attached to that screen is ranked higher, so the same question asked from the groups screen and from the trades screen gets different, more specific answers.

Response Data

{
  "runId": "run_55b…",
  "messageId": "msg_1c7…",
  "state": "queued",
  "idempotent": false
}

messageId is the id of the user message that was just stored — use it to render the bubble immediately. The answer gets its own id, returned by AIChatGetRun in result.messageId.

Errors

Code Error Description
402 AI_BUDGET_EXCEEDED The agent's daily request, token or cost limit is reached
403 AI_ACCESS_DENIED The conversation belongs to another session
404 AI_CONVERSATION_NOT_FOUND No such conversation in this scope
409 AI_CONVERSATION_BUSY A run is already active in this conversation
409 AI_AGENT_DISABLED The conversation's agent is disabled or not allowed in this chat
503 AI_QUEUE_FULL The service queue is full
503 AI_KNOWLEDGE_NOT_READY The knowledge index is still building

AI_CONVERSATION_BUSY is expected behaviour, not a failure: one run per conversation. Disable the input while an answer is being written instead of catching the error.