Create or update an AI Index

Base URL
https://{kibana_url}
Auth

Creates an AI Index with the given ID, or replaces an existing one. The request body replaces the whole record: omitted fields are removed, and omitted arrays become empty. A managed AI Index cannot be replaced and returns a 409.

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_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.

aiIndexId string · min length: 1 · max length: 256 required

The unique identifier of the AI Index.

Header parameters

kbn-xsrf string required

A required header to protect against CSRF attacks

Request body

description string · max length: 2048

Human-readable description of the AI Index.

dest object required

The data stream or index that backs the AI Index.

type enum required

The type of the backing store. data_stream for a data stream, or index for an index.

Values: data_stream index
value string · min length: 1 · max length: 1024 required

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), match type, and start with ai-index-ds- (for data_stream) or ai-index-idx- (for index). The rest of the value must be a valid AI Index ID. System indices are not allowed.

memory_enabled boolean deprecated

Whether this AI index accepts memory writes. Defaults to true when omitted. Deprecated and ignored in Serverless and in Elastic 9.7 and later.

sources union anyOf[] · max items: 100 · default: []

Additional sources that provide context for the AI Index. Defaults to an empty array when omitted.

Any of:
type enum required
Values: esql
value string · min length: 1 · max length: 10240 required

The source value; an ES|QL query when type is esql. Must be valid ES|QL.

traces union anyOf[] · max items: 100 · default: []

Trace sources linked to this AI Index. A write replaces the whole array. Defaults to an empty array when omitted.

Any of:
type enum required
Values: elastic_agent
value string · min length: 1 · max length: 10240 required

The Agent Builder agent ID.

Responses

The AI Index was updated.

application/json
status enum required
Values: updated
Base URL
https://{kibana_url}