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

# Delete a run

> Permanently delete a Loops run and the checkpoints that nothing else uses, with the Python SDK or the REST API.

Deleting a run removes the run and its saved checkpoints, except checkpoints that another resource still uses. To end a run but keep its checkpoints, [deactivate it](https://docs.baseten.co/loops/deactivate-a-run.md) instead. To remove some checkpoints and keep the run, [delete those checkpoints](https://docs.baseten.co/loops/delete-checkpoints.md). The Baseten CLI doesn't delete runs; use the Python SDK or the REST API.

Deleting an active run deactivates it first. The response lists the checkpoints Baseten kept because a resource such as a deployment still uses them, and they stay usable until that use stops.

> [!WARNING]
>
> Deleting a run permanently deletes the run and every checkpoint that nothing else uses. You can't undo it. To keep a copy of a checkpoint, [download its files](https://docs.baseten.co/loops/download-checkpoints.md) first.

The Python SDK and the `curl` examples authenticate with `BASETEN_API_KEY`. Export your [API key](https://docs.baseten.co/organization/api-keys.md) first:

```sh theme={"system"}
export BASETEN_API_KEY="YOUR_API_KEY"
```

> [tab] Python SDK
>
> **To delete a run and its checkpoints**:
>
> Call [`delete_run()`](https://docs.baseten.co/reference/sdk/loops/service-client) on a [`ServiceClient`](https://docs.baseten.co/reference/sdk/loops/service-client), replacing `<run_id>` with the run ID:
>
> ```python theme={"system"}
> from baseten.loops import ServiceClient
>
> deleted = ServiceClient().delete_run("<run_id>")
> print(deleted.id, deleted.kept_checkpoints)
> ```
>
> The result has the deleted run's `id` and a `kept_checkpoints` list. Check the list for any checkpoints Baseten kept because they're still in use.

> [tab] REST API
>
> **To delete a run and its checkpoints**:
>
> Replace `<run_id>` with the run ID from [`TrainingClient.run_id`](https://docs.baseten.co/reference/sdk/loops/training-client) or [list your runs](https://docs.baseten.co/reference/cli/baseten/loops.md#list), then send a request to [Delete a run](https://docs.baseten.co/reference/loops-api/runs/delete-a-run.md):
>
> ```bash theme={"system"}
> curl --request DELETE \
>   --url "https://api.baseten.co/v1/loops/runs/<run_id>" \
>   --header "Authorization: Bearer $BASETEN_API_KEY"
> ```
>
> The response returns the deleted run ID and a `kept_checkpoints` array. Check the array for any checkpoints Baseten kept because they're still in use.

To confirm the deletion, list your runs including inactive ones and check that the deleted run ID isn't listed:

```bash theme={"system"}
baseten loops run list --all
```

## Next steps

* [Delete a checkpoint](https://docs.baseten.co/loops/delete-checkpoints.md): Remove a kept checkpoint after its use stops.
* [Delete a run](https://docs.baseten.co/reference/loops-api/runs/delete-a-run.md): The request, its response fields, and the checkpoints Baseten keeps.
