> For the complete documentation index, see [llms.txt](https://docs.envector.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.envector.io/1.4.x/sdk-user-guide/delete/deleting-by-item-id.md).

# Deleting by Item ID

`Index.delete()` removes items by their `item_id` values — the integers returned by `Index.insert()`.

The server processes the request in two phases:

1. **Phase 1** — target items are marked for search exclusion and merge tasks are registered. The server returns a `request_id` immediately.
2. **Phase 2** — affected shards are rebuilt asynchronously. The index returns to `SEARCHABLE` when complete.

By default, the SDK polls until Phase 2 finishes so that subsequent searches see a consistent index.

***

## Usage

```python
# Capture item_ids from insert
item_ids = index.insert(vecs)

# Default: blocks until Phase 2 reaches SEARCHABLE
request_id = index.delete(item_ids=[item_ids[0], item_ids[2]])

# Fire-and-forget: returns after Phase 1
request_id = index.delete(item_ids=[item_ids[1]], await_completion=False)
```

***

## Parameters

| Parameter          | Type        | Default | Description                                                                                                  |
| ------------------ | ----------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| `item_ids`         | `List[int]` | —       | IDs returned by `Index.insert()`. Must be non-empty, contain only positive integers, and have no duplicates. |
| `await_completion` | `bool`      | `True`  | If `True`, block until the operation reaches `SEARCHABLE`. If `False`, return after Phase 1.                 |
| `timeout_s`        | `float`     | `600.0` | Maximum wait time (seconds). Used only when `await_completion=True`.                                         |
| `poll_interval_s`  | `float`     | `1.0`   | Status poll interval (seconds). Used only when `await_completion=True`.                                      |

**Returns:** `request_id` (`str`) — usable with `get_index_operation_status(operation_type="DELETE")` to track completion outside the default polling loop.

***

## Errors

| Exception                 | Cause                                                                                                                               |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `ValueError`              | The index is not loaded. Call `Index.load()` first.                                                                                 |
| `EnvectorValidationError` | `item_ids` is empty, contains duplicates, or contains non-positive values.                                                          |
| `EnvectorTimeoutError`    | Operation did not reach `SEARCHABLE` within `timeout_s`. Server keeps processing — you can re-poll using the returned `request_id`. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.envector.io/1.4.x/sdk-user-guide/delete/deleting-by-item-id.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
