Send a message and get the answer

Base URL
https://{kibana_url}
  • POST /api/chat/message
  • POST /s/{space_id}/api/chat/message
Auth

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.

Required privileges

Privileges agentBuilder:read

Path parameters

space_id string optional

An identifier for the space. If space_id is not provided in the URL, the default space is used. Refer to Spaces for more information.

Header parameters

kbn-xsrf string required

A required header to protect against CSRF attacks

Request body

agent_id string · min length: 1 · max length: 64 · default: elastic-ai-agent

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

conversation_id string · max length: 256

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.

message string · min length: 1 · max length: 100000 required

The user message to send to the agent.

Responses

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

application/json
answer string required

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

conversation_id string required

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

declined_prompts object[] · min items: 1

The prompts that the endpoint declined. In an interactive conversation, these prompts pause the agent until the user answers. Examples are tool confirmations, questions to the user, and destructive API approvals. This endpoint has no user, so it declines each prompt and tells the agent why. The property is absent if the agent raised no prompts.

message string required

The explanation the agent received in place of the prompt.

tool_id string required

The tool whose call was declined.

400

Bad Request: the request body is not valid. Possible causes are an empty or too long message, a conversation_id that is not a UUID, or an unsupported property such as connector_id or attachments.

application/json
404

Not Found: the conversation or agent was not found. Possible causes are a conversation_id that does not exist or an agent_id that the caller cannot use. If the caller cannot use the agent, the error says that the conversation was not found. This prevents callers from discovering hidden agents.

application/json
Base URL
https://{kibana_url}