Skip to main content
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.
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.

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.
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.
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.
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.
Destructive Operation: prune commands bypass permission checks and wipe the underlying storage directly. Do not use in production.
# Remove all data files
await cognee.prune.prune_data()

# Remove everything (graph, vector, metadata, cache)
await cognee.prune.prune_system(metadata=True)

CLI and HTTP API

For command-line usage and HTTP API endpoints, refer to their dedicated documentation pages:
DELETE /api/v1/delete is deprecated. Use the datasets endpoints instead.