# What a delete would remove and keep, and what holds it now.

> A dry run of `DELETE /crews/{id}`, `/projects/{id}`, `/artifacts/{id}`, `/crews/{id}/branches` or `/tasks/{id}/branch` (`kind` and `id`).
> https://koi.dog/docs/api/costs-and-settings/check-deletion/

`GET /api/v1/deletions/check` · Scope: `read`

Changes nothing. Answers whether the delete would go ahead (`allowed`), the `error.code` it would refuse with (`refusal`), each reason as the 409 would give it with its `code` and `next` (`holds`), what it would remove (`removes`, counted now) and keep, and the call that deletes it with the scopes it needs. Something already deleted answers `alreadyDeleted: true`; an id that never existed is `404`. Needs only `read`, so a page can show the reasons before anyone holds `approve`. A GET: no Idempotency-Key.

## Query parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `kind` | `enum` | yes | Which delete to check, one value: a crew, a project, an artifact, a crew's branches or one task's branch. One of `crew`, `project`, `artifact`, `crew_branches`, `task_branch`. |
| `id` | `string` | yes | The crew, project or artifact id; for `crew_branches` the crew's, for `task_branch` the task's. At least 1 character. |

## Response.

200 OK · JSON object

## Request.

```sh
curl "https://api.koi.dog/api/v1/deletions/check?kind=$KIND&id=$ID" \
    -H "Authorization: Bearer $KOIDOG_API_KEY"
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/deletions/check?kind=${process.env.KIND}&id=${process.env.ID}`, {
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
  },
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.get(
    f"https://api.koi.dog/api/v1/deletions/check?kind={os.environ['KIND']}&id={os.environ['ID']}",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "kind": "crew",
  "id": "string",
  "name": "string",
  "projectId": "string",
  "crewId": "string",
  "allowed": false,
  "alreadyDeleted": false,
  "refusal": "string",
  "holds": [],
  "removes": {
    "crews": 0,
    "tasks": 0,
    "agents": 0,
    "runs": 0,
    "logLines": 0,
    "artifacts": 0,
    …
  },
  "branches": [],
  "kept": [],
  "next": [],
  "delete": {
    "label": "string",
    …
  },
  …
}
```
