agent builder

Send a message and get the answer

Spaces method and path for this operation:

<div><span class="operation-verb post">post</span>&nbsp;<span class="operation-path">/s/{space_id}/api/chat/message</span></div>

Refer to Spaces for more information.

Send a message to an agent and get its text answer. Use this synchronous endpoint in scripts and command-line tools. The response contains only the answer and the conversation ID. To continue the conversation, include the returned conversation_id in the next request.

The agent runs without a user, so the endpoint declines every prompt that the agent raises, such as a tool confirmation, a question, or a destructive API approval. The declined_prompts property lists these prompts. This endpoint does not support attachments.

The agentBuilder:experimentalFeatures advanced setting must be enabled. If it is disabled, the endpoint returns a 404 response.<br/><br/>[Required authorization] Route required privileges: agentBuilder:read.

post/api/chat/message

Request

  • Base URL
    https://localhost:5601
  • URL
    https://localhost:5601/api/chat/message
  • Auth
    • API key in header Authorization
    • or HTTP basic

Headers

kbn-xsrfstring required
Example:true

A required header to protect against CSRF attacks

Request body

agent_idstring

The ID of the agent to send the message to. Defaults to the default Elastic AI agent.

conversation_idstring

The ID of an existing conversation to continue. Omit it to start a new conversation; the response carries the ID to reuse on the next call.

messagestring required

The user message to send to the agent.

Response

The agent answered. The response contains the answer and the ID of the conversation that stores the exchange.

answerstring required

The agent's final text answer. Empty when the agent finished without a message.

conversation_idstring required

The conversation the message was added to: the one requested, or the one created for it.

Changes

No operation changes recorded.