Spaces method and path for this operation:
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.
[Required authorization] Route required privileges: agentBuilder:read.
Body
-
The ID of the agent to send the message to. Defaults to the default Elastic AI agent.
Minimum length is
1, maximum length is64. Default value iselastic-ai-agent. -
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.
Maximum length is
256. -
The user message to send to the agent.
Minimum length is
1, maximum length is100000.
Responses
-
The agent answered. The response contains the answer and the ID of the conversation that stores the exchange.
-
Bad Request: the request body is not valid. Possible causes are an empty or too long
message, aconversation_idthat is not a UUID, or an unsupported property such asconnector_idorattachments. -
Not Found: the conversation or agent was not found. Possible causes are a
conversation_idthat does not exist, anagent_idthat the caller cannot use, or a disabledagentBuilder:experimentalFeaturesadvanced setting. If the caller cannot use the agent, the error says that the conversation was not found. This prevents callers from discovering hidden agents.
curl \
-X POST "${KIBANA_URL}/api/chat/message" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-d '{
"message": "What is Elasticsearch?",
"agent_id": "elastic-ai-agent"
}'
POST kbn://api/chat/message
{
"message": "What is Elasticsearch?",
"agent_id": "elastic-ai-agent"
}
{
"agent_id": "elastic-ai-agent",
"conversation_id": "696ccd6d-4bff-4b26-a62e-522ccf2dcd16",
"message": "And how does it differ from Kibana?"
}
{
"message": "What is Elasticsearch?"
}
{
"agent_id": "elastic-ai-agent",
"message": "What is Elasticsearch?"
}
{
"answer": "I could not run the reindex because it requires confirmation, which is not available here. You can run it from a conversation in Kibana instead.",
"conversation_id": "696ccd6d-4bff-4b26-a62e-522ccf2dcd16",
"declined_prompts": [
{
"message": "Agent running in non-interactive mode, user input not available - execution was declined",
"tool_id": "reindex-logs"
}
]
}
{
"answer": "Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease.",
"conversation_id": "696ccd6d-4bff-4b26-a62e-522ccf2dcd16"
}
{
"error": "Bad Request",
"message": "[request body.message]: value has length [0] but it must have a minimum length of [1].",
"statusCode": 400
}
{
"error": "Bad Request",
"message": "[request body.connector_id]: Additional properties are not allowed ('connector_id' was unexpected)",
"statusCode": 400
}
{
"attributes": {
"trace_id": "8d4f2a3b-1c5e-4a9b-9f0d-2e6c1a3d4f5e"
},
"error": "Not Found",
"message": "Conversation 696ccd6d-4bff-4b26-a62e-522ccf2dcd16 not found",
"statusCode": 404
}