# Remove a crew's branches from the server's git mirror.

> Every `koidog/<crew>/…` branch and the crew's private merge refs, from the mirror the server keeps (and its saved copy).
> https://koi.dog/docs/api/crews/delete-crew-branches/

`DELETE /api/v1/crews/{id}/branches` · Scopes: `crews`, `approve`

Only for a crew that ended (`409 crew_live`). Never a project's default branch, and never anything on GitHub: Koidog keeps every branch it pushed there (D22). A retry of one of its agents afterwards starts the task again from the project's default branch. Repeating it removes nothing and answers the branches as `missing`. The timeline records the key ID, action and outcome.

## Path parameters.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | The crew'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). |

## Response.

200 OK · JSON object

## Request.

```sh
curl -X DELETE "https://api.koi.dog/api/v1/crews/$ID/branches" \
    -H "Authorization: Bearer $KOIDOG_API_KEY"
```

```js
const res = await fetch(`https://api.koi.dog/api/v1/crews/${process.env.ID}/branches`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
  },
});
console.log(await res.json());
```

```python
import os

import requests

r = requests.delete(
    f"https://api.koi.dog/api/v1/crews/{os.environ['ID']}/branches",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "crewId": "string",
  "taskId": "string",
  "deleted": [],
  "missing": [],
  "github": "not_touched",
  "note": "string",
  …
}
```
