> ## 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.

# Set a Training Jobs checkpoint expiry

> Have Baseten delete a training job checkpoint after a set time with the Training API, and see which expired checkpoints Baseten keeps.

A checkpoint expiry tells Baseten to delete the checkpoint after a set time. It's also the only way to delete a single Training Jobs checkpoint: without an expiry, a checkpoint stays until you [delete its job or project](#delete-checkpoints-with-their-job-or-project).

Your organization may have a default expiry. If so, each new checkpoint gets it when it syncs. Changing the default doesn't affect existing checkpoints.

> [!WARNING]
>
> Baseten permanently deletes expired checkpoints once a day, after the job has stopped. If a checkpoint expires while its job is still running, Baseten deletes it within about a day after the job stops.

## Set a checkpoint expiry

The Baseten CLI doesn't set a checkpoint expiry, so set it with the Training API.

**To set a checkpoint expiry**:

1. Find the checkpoint's `id` by [listing the job's checkpoints with the Training API](https://docs.baseten.co/training/download-checkpoints.md#list-checkpoints). The request URL takes that `id`. The response's `checkpoint_name`, and its deprecated `checkpoint_id`, hold the checkpoint's name, such as `checkpoint-50`, and the CLI listing shows those names instead of IDs.

2. Send a request to [Set a training job checkpoint TTL](https://docs.baseten.co/reference/training-api/set-a-training-job-checkpoint-ttl.md). The `curl` examples authenticate with `BASETEN_API_KEY`. Export your [API key](https://docs.baseten.co/organization/api-keys.md) first.

   Replace `<project_id>`, `<job_id>`, and `<checkpoint_id>` with the project ID, the job ID, and the checkpoint's `id`. `ttl_seconds` counts from now, from 3600 (1 hour) to 315360000 (10 years). To keep the checkpoint for 30 days, run:

   ```bash theme={"system"}
   curl --request PUT \
     --url "https://api.baseten.co/v1/training_projects/<project_id>/jobs/<job_id>/checkpoints/<checkpoint_id>/ttl" \
     --header "Authorization: Bearer $BASETEN_API_KEY" \
     --header "Content-Type: application/json" \
     --data '{"ttl_seconds": 2592000}'
   ```

   The response returns the checkpoint with its new `expires_at`, the time Baseten deletes it.

**To remove a checkpoint's expiry**:

Send `null` as `ttl_seconds`, so the checkpoint never expires:

```bash theme={"system"}
curl --request PUT \
  --url "https://api.baseten.co/v1/training_projects/<project_id>/jobs/<job_id>/checkpoints/<checkpoint_id>/ttl" \
  --header "Authorization: Bearer $BASETEN_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"ttl_seconds": null}'
```

The response's `expires_at` is `null`.

The request fails in these cases:

* `404`: the job has no checkpoint with that ID.
* `409`: Baseten hasn't confirmed that the job's checkpoint upload finished. That confirmation usually takes a few minutes after the job stops, and a checkpoint without it can't expire.

## When expired checkpoints are deleted

Baseten keeps an expired checkpoint if:

* It has ever been [deployed](https://docs.baseten.co/training/deployment.md).
* A Loops run or sampler uses it as its base model.
* A training job is still copying it.
* It's inside the folder of another checkpoint that's kept.

> [!WARNING]
>
> When all of a job's checkpoints are deleted, Baseten also deletes any other files left in the job's checkpoint storage.

## Delete checkpoints with their job or project

Deleting a training job deletes all of its undeployed checkpoints, and deleting a project deletes them for every job in it. See [Delete a job](https://docs.baseten.co/training/delete-jobs.md#delete-a-job) and [Delete a project](https://docs.baseten.co/training/delete-jobs.md#delete-a-project) for what each deletion removes and what it leaves in place.

## Next steps

* [List and download checkpoints](https://docs.baseten.co/training/download-checkpoints.md): Keep a local copy before a checkpoint expires.
* [Deploy a checkpoint](https://docs.baseten.co/training/deployment.md): Serve a checkpoint as a model.
