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

# Purge data using the Data plugin

> Use the Data plugin to delete data from Cognite Data Fusion (CDF).

Use the `cdf data purge` command to delete data from Cognite Data Fusion (CDF). The command has subcommands for deleting different types of data, including data sets, spaces, and instances.

<Warning>
  Purging data is a destructive operation that cannot be undone. Always verify what you are deleting before running purge commands.
</Warning>

## Prerequisites

Before purging data, ensure you have:

* Installed and configured the Cognite Toolkit.
* Authenticated with CDF using appropriate credentials.
* Admin or delete permissions for the data you want to purge.
* Backed up any data you might need to restore later.

## Purge data sets

To delete all data in a data set, use the `dataset` subcommand. You can also specify to include all configuration resources in the data set.

```bash theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
cdf data purge dataset <dataset-external-id>
```

## Purge spaces

To delete all data in a space, use the `space` subcommand. This is typically used to delete a schema space (a space containing data models, views, and containers).

<Note>
  Do not use this command to delete large amounts of data unless you intend to delete **everything** in the space.
</Note>

```bash theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
cdf data purge space <space-external-id>
```

<Note>
  By default, this command will not delete nodes that are time series or files. This is to prevent accidentally losing datapoints
  and file content. To delete these nodes as well, use the `--delete-datapoints` and `--delete-file-content` flags.
</Note>

## Purge instances

To delete instances, use the `instances` subcommand.

<Note>
  This command is used to unlink nodes that are time series or files. This means that the nodes were created with the migration plugin and have linked classical time series and files to them. Unlinking allows you to reverse this operation, by first removing the link between the node and the time series/file, and then deleting the node. Thus, the classical time series/file will remain in CDF after the purge operation including the datapoints and file content. Note that this is only the case for nodes that were created with the migration plugin.
</Note>

You can select which instances to delete in multiple ways:

### Delete by view

Delete all instances that have data in a view:

```bash theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
cdf data purge instances --view <space>:<view-external-id>/<version>
```

### Delete by instance space

Delete all instances in an instance space:

```bash theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
cdf data purge instances --instance-space <space-external-id>
```

### Delete by CSV

Delete instances listed in a CSV file:

```bash theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
cdf data purge instances --list <path-to-csv-file>
```

The CSV file should have three columns: `space`, `externalId`, and `instanceType`. For example:

```csv title="to-delete.csv" theme={"languages":{"custom":["/_languages/kuiper.json","../_languages/kuiper.json"]}}
space,externalId,instanceType
my-space,node1,node
my-space,node2,node
my-other-space,edge1,edge
my-other-space,edge2,edge
```

The `space` column specifies the space the instance belongs to, the `externalId` column specifies the instance's
external ID, and the `instanceType` column specifies whether the instance is a `node` or an `edge`.

## Further reading

* [Upload data using the Data plugin](/cdf/deploy/cdf_toolkit/guides/plugins/data_plugin/upload)
* [Download data using the Data plugin](/cdf/deploy/cdf_toolkit/guides/plugins/data_plugin/download)
* [Cognite Toolkit documentation](/cdf/deploy/cdf_toolkit)
