# Delete many runs

**POST** `/api/runs/delete`

Deletes up to 500 finished runs in one call. Others are skipped.

Needs [an API token](https://docs.gorunner.io/api/authentication#scopes) with the **Cancel and delete** permission for runs (`run:manage`).

## Parameters

### Body

- `ids` · Required · array of UUIDs: From 1 to 500 run IDs. One that isn’t a UUID is dropped without counting.

## The counts

`requested` counts the IDs that were UUIDs, a repeat counted again. `skipped` is the ones not deleted: runs not finished, in another workspace, gone, or repeats. A call with no valid ID answers 200 with every count at 0.

It is a POST because it has a body. There is no undo.

## Responses

- 200 OK

  Done. Compare `deleted` with `requested`.

- 400 `VALIDATION_ERROR`

  The body isn’t `{"ids": […]}`, or has no IDs or more than 500.

- 403 `FORBIDDEN`

  The token lacks the **Cancel and delete** permission for runs.

- 500 `INTERNAL_ERROR`

  The delete failed. Try again.

Any call can also answer: [`401 UNAUTHORIZED`](https://docs.gorunner.io/errors#UNAUTHORIZED) · [`401 TOKEN_ENDED`](https://docs.gorunner.io/errors#TOKEN_ENDED) · [`403 TOKEN_SURFACE_OFF`](https://docs.gorunner.io/errors#TOKEN_SURFACE_OFF) · [`403 FEATURE_OFF`](https://docs.gorunner.io/errors#FEATURE_OFF) · [`403 EMBED_NOT_ALLOWED`](https://docs.gorunner.io/errors#EMBED_NOT_ALLOWED) · [`403 EMBED_NOT_AVAILABLE`](https://docs.gorunner.io/errors#EMBED_NOT_AVAILABLE) · [`403 ACCOUNT_SUSPENDED`](https://docs.gorunner.io/errors#ACCOUNT_SUSPENDED) · [`413 PAYLOAD_TOO_LARGE`](https://docs.gorunner.io/errors#PAYLOAD_TOO_LARGE) · [`415 INVALID_CONTENT_TYPE`](https://docs.gorunner.io/errors#INVALID_CONTENT_TYPE) · [`429 RATE_LIMITED`](https://docs.gorunner.io/errors#RATE_LIMITED) · [`503 BUSY`](https://docs.gorunner.io/errors#BUSY) · [`503 PAUSED`](https://docs.gorunner.io/errors#PAUSED) · [`503 SERVICE_UNAVAILABLE`](https://docs.gorunner.io/errors#SERVICE_UNAVAILABLE). See [Errors](https://docs.gorunner.io/api/errors#by-status).

Request

**curl**

```bash
GORUNNER="https://api.gorunner.io"
GORUNNER_TOKEN="grt_…"  # needs Cancel and delete for runs

curl -X POST "$GORUNNER/api/runs/delete" \
  -H "Authorization: Bearer $GORUNNER_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": [
      "8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
      "1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26"
    ]
  }'
```

**JavaScript**

```js
const GORUNNER = "https://api.gorunner.io";
const TOKEN = process.env.GORUNNER_TOKEN;

const res = await fetch(`${GORUNNER}/api/runs/delete`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    ids: [
      "8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
      "1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26",
    ],
  }),
});
const { data } = await res.json();
```

**Python**

```python
import os, requests

GORUNNER = "https://api.gorunner.io"
TOKEN = os.environ["GORUNNER_TOKEN"]

res = requests.post(
    f"{GORUNNER}/api/runs/delete",
    headers={"Authorization": f"Bearer {TOKEN}"},
    json={
      "ids": [
        "8f0c41d2-6b7e-4c1a-9d3f-2a5b7c9e1f04",
        "1d7f3b9e-2c4a-4e6b-8d0f-5a3c9e1b7d26",
      ],
    },
)
data = res.json()["data"]
```

Response · 200 OK

```json
{
  "data": {
    "deleted": 1,
    "requested": 2,
    "skipped": 1
  }
}
```

**Every field**

### Body

- `ids` · Required · array of UUIDs: Between 1 and 500 run ids. The 1-500 bound is checked on the RAW list; entries that are not valid UUIDs are then dropped silently.

### Response · 200 OK

- `data` · object
  - `deleted` · integer: Runs actually removed.
  - `requested` · integer: How many posted ids were parseable UUIDs, an id posted twice counted twice — NOT the number of ids you posted.
  - `skipped` · integer: `requested - deleted`: ids that named an in-flight/paused run, a run in another workspace, a run that no longer exists, or a repeat of an id already deleted.

Related: [Delete a run](https://docs.gorunner.io/api/runs/delete-run) · [Cancel many runs](https://docs.gorunner.io/api/runs/cancel-runs-bulk)

Source: https://docs.gorunner.io/api/runs/delete-runs-bulk
