---
title: "Preview or run retention using each selected schedule's configured retention days."
method: POST
path: "/backups/cleanup"
tags: ["Backups"]
---

# Preview or run retention using each selected schedule's configured retention days.

`POST /backups/cleanup`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/backups/cleanup`
- Auth: HTTP bearer

## Query parameters

- `dry_run` boolean
- `schedule_id` integer, nullable

## Request body

- CleanupExpiredBackupsRequest
  - `expected_backup_ids` string[], nullable: Exact candidates returned by the dry run. Execution fails if the retention selection has changed since preview.

## Response `200`

Retention cleanup completed

- RetentionCleanupReport
  - `candidate_backup_ids` string[], required: Capped sample of backups selected by the retention policy.
  - `candidate_backup_ids_truncated` boolean, required
  - `deleted` integer, required
  - `deleted_backup_ids` string[], required: Capped sample of deleted backup UUIDs for audit attribution.
  - `deleted_backup_ids_truncated` boolean, required
  - `dry_run` boolean, required: True when this report is a non-destructive preview.
  - `expired` integer, required
  - `failed` integer, required
  - `failures` RetentionCleanupFailure[], required: Capped diagnostic sample; `failed` remains the authoritative total.
    - `backup_id` string, required
    - `deleted_objects` integer, required
    - `partial` boolean, required
    - `reason` string, required
  - `partially_deleted_backup_ids` string[], required
  - `partially_deleted_backup_ids_truncated` boolean, required
  - `schedule_id` integer, nullable: Schedule scope, or `None` when every schedule was considered.

## Other responses

- `400`: Missing or invalid preview candidate list
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Schedule or backup not found
- `409`: Cleanup preview is stale
- `500`: Cleanup could not be started

## Changes

- **2026-11-09** `12896146b193`: 6 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
  - removed the required property `extensions` from the response with the `404` status
  - …2 more
- **2026-10-05** `4b228ebed583`: 6 info
  - added the optional property `status` to the response with the `400` status
  - added the optional property `status` to the response with the `401` status
  - added the optional property `status` to the response with the `403` status
  - added the optional property `status` to the response with the `404` status
  - …2 more
- **2026-10-05** `63a80791dc58`: 6 warning
  - removed the optional property `status` from the response with the `400` status
  - removed the optional property `status` from the response with the `401` status
  - removed the optional property `status` from the response with the `403` status
  - removed the optional property `status` from the response with the `404` status
  - …2 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/backups/cleanup/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
