# Remove run folders no run holds from a machine.

> The node removes a folder only when its run is not active there, the server has acknowledged the run's result and final bundle, and the server does not still want the run; `olderThanDays` and `runIds` narrow it further.
> https://koi.dog/docs/api/nodes/gc-node/

`POST /api/v1/nodes/{id}/gc` · Scopes: `config`, `approve`

`dryRun` reports and removes nothing. The same as `koidog node gc` on the machine. Waits up to 60 seconds. `409 offline` and `409 not_supported` as for the list. Deletes files on a machine, so a key needs `approve` as well as `config`. The timeline records the key ID, action and outcome.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The machine's id. |

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

## Body.

An omitted body is read as `{}`.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `olderThanDays` | `0–3650` | no | Only folders not changed for at least this many days. Left out: any age. |
| `dryRun` | `boolean` | no | Report what would be removed and remove nothing. Default `false`. |
| `runIds` | `array` | no | Only these run ids. 1 to 500 items. |

## Response.

200 OK · JSON object

- **422 validation_failed**: Each schema error appears in `details`.

## Request.

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

```js
const res = await fetch(`https://api.koi.dog/api/v1/nodes/${process.env.ID}/gc`, {
  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(
    f"https://api.koi.dog/api/v1/nodes/{os.environ['ID']}/gc",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "nodeId": "string",
  "at": "string",
  "dryRun": false,
  "olderThanDays": 0,
  "removed": [],
  "kept": [],
  "bytesFreed": 0,
  "errors": []
}
```
