Create an AI Index
- Base URL
-
https://{kibana_url}
- POST /api/context_engine/ai_index
- POST /s/{space_id}/api/context_engine/ai_index
Creates an AI Index record attached to a data stream or index. Fails with a 409 if an AI Index with the same ID already exists.
Each ES|QL source added also gets an index metadata automation, installed as a separate workflow and attached to the AI Index as the calling user, who needs the workflow create and update privileges for it; removing the source deletes the workflow, which needs the delete privilege. The save succeeds whether or not that works. When an automation could not be installed or removed, the response lists it under warnings.
Returns a 404 response when Context Engine is turned off in this space (contextEngine:enabled).
For more information, refer to the Context Engine documentation.
Required privileges
contextEngine:write
Path parameters
-
space_idstringoptional -
An identifier for the space. If
space_idis not provided in the URL, the default space is used. Refer to Spaces for more information.
Request body
-
automationsobject[] · max items: 100 · default: [] -
Automations associated with the AI Index. Defaults to an empty array when omitted.
-
destobjectrequired -
The data stream or index that backs the AI Index.
-
typeenumrequired -
The type of the backing store.
data_streamfor a data stream, orindexfor an index. -
Values:
data_streamindex -
valuestring · min length: 1 · max length: 1024required -
The data stream or index (e.g.
ai-index-ds-foo,ai-index-idx-foo) the AI Index is attached to. Must name a single data stream or index (no wildcards or comma-separated lists), matchtype, and start withai-index-ds-(fordata_stream) orai-index-idx-(forindex). The rest of the value must be a valid AI Index ID. System indices are not allowed. -
feedback_analysisobject -
The recurring feedback analysis, which reads agent signals and proposes improvement actions for the AI Index.
-
agent_idstring · max length: 256 -
Agent Builder agent ID that runs this index’s feedback-loop analysis.
-
allowed_actionsenum[] · max items: 9 -
Improvement actions the analysis may propose. An empty list is observe-only.
-
Values:
add_kiedit_kiremove_kiadd_workflowedit_workflowremove_workflowadd_sourceedit_sourceremove_source -
Default:
["add_ki","edit_ki","remove_ki","add_workflow","edit_workflow","remove_workflow","add_source","edit_source","remove_source"] -
enabledbooleanrequired -
Desired state of the recurring analysis. The scheduler stays authoritative for whether it is actually running.
-
signal_filterstring · max length: 4096 -
KQL narrowing which signals this index analyzes, for example
tags: query_error. -
memory_enabledbooleandeprecated -
Whether this AI index accepts memory writes. Defaults to true when omitted. Deprecated and ignored in Serverless and in Elastic 9.7 and later.
-
sourcesunion anyOf[] · max items: 100 · default: [] -
Additional sources that provide context for the AI Index. Defaults to an empty array when omitted.
- Any of:
Responses
The AI Index was created.
The request was invalid, for example a malformed dest, an invalid ES|QL source, or an unresolvable connector source or trace.
Elasticsearch denied the index trace lookup outright; the caller lacks index privileges for it.
Context Engine is turned off in this space.