---
title: "Delete an AI Index"
method: DELETE
path: "/api/context_engine/ai_index/{aiIndexId}"
tags: ["context engine"]
---

# Delete an AI Index

`DELETE /api/context_engine/ai_index/{aiIndexId}`

**Spaces method and path for this operation:**

<div><span class="operation-verb delete">delete</span>&nbsp;<span class="operation-path">/s/{space_id}/api/context_engine/ai_index/{aiIndexId}</span></div>

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Deletes an AI Index by ID.

By default, the API preserves the backing data stream or index, its Knowledge Indicators, and attached workflow automations. Set `delete_knowledge_indicators` to `true` to delete the backing data stream or index and its Knowledge Indicators. Set `delete_automations` to `true` to delete the attached workflow automations.

The API does not delete the backing data stream or index when another AI Index uses the same destination.

Returns a 404 response when Context Engine is turned off in this space (`contextEngine:enabled`).

**For more information, refer to the [Context Engine documentation](https://www.elastic.co/docs/explore-analyze/ai-features/context-engine).**<br/><br/>[Required authorization] Route required privileges: contextEngine:write. Extended privileges (optional, expand functionality when granted): workflowsManagement:delete.

## Path parameters

- `aiIndexId` string, required

## Query parameters

- `delete_knowledge_indicators` boolean
- `delete_automations` boolean

## Headers

- `kbn-xsrf` string, required

## Response `200`

The AI Index entry was deleted. `errors` lists any best-effort cleanup failures.

- object
  - `acknowledged` boolean, required — Whether the AI Index entry was deleted.
  - `errors` string[], required — Best-effort cleanup errors after the entry was deleted, if any.

## Other responses

- `404` — No AI Index with the given ID exists in the current space, or Context Engine is turned off in this space.
- `409` — The AI Index is managed and cannot be deleted.

---

[API](https://skmtc.dev/elastic/apis/kibana-apis.md) · [All operations](https://skmtc.dev/elastic/apis/kibana-apis/llms.txt) · [OpenAPI document](https://skmtc.dev/elastic/apis/kibana-apis/revisions/a6aad934034f?raw)
