# Run the retention sweep now.

> Applies the retention settings at once, as the hourly sweep does, and answers the sweep.
> https://koi.dog/docs/api/costs-and-settings/run-cleanup/

`POST /api/v1/cleanup/sweep` · Scope: `config`

Machines are asked to clean their run folders and waited for up to 60 seconds each. With every setting `null` it removes nothing. `409 sweep_running` while one is under way. The timeline records the key ID, action and outcome.

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Retry the same request with the same key. [Retry rules](https://koi.dog/docs/api/#retries). |

## Response.

200 OK · JSON object

## Request.

```sh
curl -X POST https://api.koi.dog/api/v1/cleanup/sweep \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)"
```

```js
const res = await fetch("https://api.koi.dog/api/v1/cleanup/sweep", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
  },
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://api.koi.dog/api/v1/cleanup/sweep",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "id": "string",
  "trigger": "schedule",
  "startedAt": "string",
  "finishedAt": "string",
  "retention": {
    "workspacesDays": 0,
    "artifactsDays": 0,
    "endedCrewsDays": 0
  },
  "crewsDeleted": 0,
  "artifactsDeleted": 0,
  "bundlesDeleted": 0,
  "workspacesRemoved": 0,
  "bytesFreed": 0,
  "skipped": [],
  "nodes": [],
  "errors": [],
  …
}
```
