Send a message and get the answer
https://{kibana_url}
- POST /api/chat/message
- POST /s/{space_id}/api/chat/message
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.
Request
-
agent_idstring · min: 1 · max: 64 · default: elastic-ai-agent -
The ID of the agent to send the message to. Defaults to the default Elastic AI agent.
-
conversation_idstring · max: 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.
-
messagestring · min: 1 · max: 100000required -
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.
-
answerstringrequired -
The agent's final text answer. Empty when the agent finished without a message.
-
conversation_idstringrequired -
The conversation the message was added to: the one requested, or the one created for it.
-
declined_promptsobject · min: 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.
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.
Not Found: the conversation or agent was not found. Possible causes are a conversation_id that does not exist, an agent_id that the caller cannot use, or a disabled agentBuilder:experimentalFeatures advanced setting. If the caller cannot use the agent, the error says that the conversation was not found. This prevents callers from discovering hidden agents.