Spaces method and path for this operation:
Refer to Spaces for more information.
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.
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 authorization] Route required privileges: contextEngine:write.
Body
-
Automations associated with the AI Index. Defaults to an empty array when omitted.
Not more than
100elements. Default value is[](empty). -
Human-readable description of the AI Index.
Maximum length is
2048. -
The data stream or index that backs the AI Index.
Additional properties are NOT allowed.
-
The recurring feedback analysis, which reads agent signals and proposes improvement actions for the AI Index.
Additional properties are NOT allowed.
-
The unique identifier of the AI Index.
Minimum length is
1, maximum length is256. -
Whether this AI index accepts memory writes. Defaults to true when omitted.
-
Additional sources that provide context for the AI Index. Defaults to an empty array when omitted.
Not more than
100elements. Default value is[](empty). -
Trace sources linked to this AI Index. A write replaces the whole array. Defaults to an empty array when omitted.
Not more than
100elements. Default value is[](empty).
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
indextrace lookup outright; the caller lacks index privileges for it. -
Context Engine is turned off in this space.
-
An AI Index with the same ID already exists, or the write conflicted.
curl \
-X POST "https://${KIBANA_URL}/api/context_engine/ai_index" \
-H "Authorization: ApiKey ${API_KEY}" \
-H "kbn-xsrf: true" \
-H "Content-Type: application/json" \
-d '{
"id": "customer_support",
"description": "Knowledge about customer support cases.",
"dest": { "type": "data_stream", "value": "ai-index-ds-customer-support" },
"automations": [{ "type": "workflow", "value": "8f1c2d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f" }],
"sources": [{ "type": "esql", "value": "FROM support-cases | LIMIT 100" }],
"traces": [
{ "type": "elastic_agent", "value": "elastic-ai-agent" },
{ "type": "index", "value": "traces-support" }
]
}'
POST kbn:/api/context_engine/ai_index
{
"id": "customer_support",
"description": "Knowledge about customer support cases.",
"dest": { "type": "data_stream", "value": "ai-index-ds-customer-support" },
"automations": [{ "type": "workflow", "value": "8f1c2d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f" }],
"sources": [{ "type": "esql", "value": "FROM support-cases | LIMIT 100" }],
"traces": [
{ "type": "elastic_agent", "value": "elastic-ai-agent" },
{ "type": "index", "value": "traces-support" }
]
}
{
"automations": [
{
"type": "workflow",
"value": "8f1c2d3e-4b5a-6c7d-8e9f-0a1b2c3d4e5f"
}
],
"description": "Knowledge about customer support cases.",
"dest": {
"type": "data_stream",
"value": "ai-index-ds-customer-support"
},
"id": "customer_support",
"sources": [
{
"type": "esql",
"value": "FROM support-cases | LIMIT 100"
}
],
"traces": [
{
"type": "elastic_agent",
"value": "elastic-ai-agent"
},
{
"type": "index",
"value": "traces-support"
}
]
}
{
"status": "created"
}
{
"error": "Bad Request",
"message": "dest.value 'support-cases' is not allowed: it must start with 'ai-index-ds-'",
"statusCode": 400
}
{
"error": "Forbidden",
"message": "security_exception: action [indices:admin/resolve/index] is unauthorized for user [jdoe] with effective roles [support_reader] on indices [traces-support], this action is granted by the index privileges [view_index_metadata,manage,read,all]",
"statusCode": 403
}
{
"error": "Not Found",
"message": "Not Found",
"statusCode": 404
}
{
"error": "Conflict",
"message": "AI index 'customer_support' already exists",
"statusCode": 409
}