Type to search.

Send a message and get the answer

Base URL
https://{kibana_url}
  • POST /api/chat/message
  • POST /s/{space_id}/api/chat/message
Auth The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability Preview This functionality is in technical preview and is ready for evaluation. Use with caution in production; it is not recommended for mission-critical workloads. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features. Specific Support terms apply. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

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.

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