> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete

> Remove data from your knowledge graph

<Note>
  `delete`-style APIs are legacy operations. In Cognee v1.0, most users should use [forget()](/core-concepts/main-operations/forget) instead for item, dataset, and full-memory deletion. Low-level `prune` resets remain separate destructive maintenance tools.
</Note>

Cognee allows you to remove data at various levels of granularity: individual data items, entire datasets, or all datasets you have permission to delete.

## Overview

When you delete data in Cognee, the system performs a cleanup operation that removes:

1. **Graph Data:** Nodes and edges associated with the data item are removed from the graph database (e.g., Neo4j, FalkorDB).
2. **Vector Embeddings:** Embeddings generated for the data are removed from the vector store (e.g., Qdrant, LanceDB).
3. **Metadata:** Records in the relational database tracking the data item are deleted.
4. **Storage:** Raw files are removed only when Cognee owns the file and no other data item references it.

<Note>
  **Shared Nodes:** If a node in the graph (like an entity "New York") is shared by multiple data items, it is only removed when the *last* data item referencing it is deleted. This ensures the integrity of the remaining graph.
</Note>

## Permissions

Deletion is a privileged operation. To delete data, you must have the `delete` permission on the dataset containing the data.

* If you created the dataset, you typically have this permission by default.
* In multi-user environments, administrators can grant or revoke this permission.

## Python SDK

The Python SDK is the primary way to manage data programmatically.

### Delete a Single Data Item

To delete a specific document or text entry, you need its `data_id` and the `dataset_id` it belongs to.

```python theme={null}
import cognee

# 1. Find the dataset and data ID
datasets = await cognee.datasets.list_datasets()
my_dataset = datasets[0]
data_items = await cognee.datasets.list_data(my_dataset.id)
item_to_delete = data_items[0]

# 2. Delete the item
await cognee.datasets.delete_data(
    dataset_id=my_dataset.id,
    data_id=item_to_delete.id
)
```

### Delete an Entire Dataset

Removing a dataset deletes all data items contained within it and the dataset container itself.

```python theme={null}
await cognee.datasets.empty_dataset(
    dataset_id=my_dataset.id
)
```

### Delete All Data

You can wipe all datasets and data that your user has permission to delete.

```python theme={null}
await cognee.datasets.delete_all()
```

### Development Reset (`prune`)

For local development and testing, you might want to completely reset the system, including caches and system metadata.

<Warning>
  **Destructive Operation:** `prune` commands bypass permission checks and wipe the underlying storage directly. Do not use in production.
</Warning>

Cognee stores data in two separate places that must be cleared independently:

| Layer            | What it holds                                                    | How to clear        |
| ---------------- | ---------------------------------------------------------------- | ------------------- |
| **File storage** | Raw uploaded files on disk or S3                                 | `prune_data()`      |
| **Databases**    | Graph nodes/edges, vector embeddings, relational metadata, cache | `prune_system(...)` |

```python theme={null}
import cognee

# Step 1 — wipe raw files from disk / S3 (DATA_ROOT_DIRECTORY)
await cognee.prune.prune_data()

# Step 2 — wipe all databases (graph, vector, relational metadata, cache)
await cognee.prune.prune_system(metadata=True)
```

You can also do a partial reset — for example, clear just the graph and vector
stores while keeping relational metadata and raw files intact:

```python theme={null}
# Clear only graph and vector stores (keep metadata and files)
await cognee.prune.prune_system(graph=True, vector=True, metadata=False, cache=False)
```

See the [`prune` API reference](/python-api/prune) for the full parameter list.

## CLI and HTTP API

For command-line usage and HTTP API endpoints, refer to their dedicated documentation pages:

<CardGroup cols={2}>
  <Card title="CLI Reference" icon="terminal" href="/cognee-cli/overview#delete-data">
    Learn how to delete data using `cognee-cli delete`.
  </Card>

  <Card title="HTTP API Reference" icon="code" href="/api-reference/introduction#data-deletion">
    See `DELETE` endpoints and `curl` examples.
  </Card>
</CardGroup>

<Note>
  `DELETE /api/v1/delete` is deprecated. Use the `datasets` endpoints instead.
</Note>
