# Delete a document folder

> Deletes a document folder, as Delete folder does.

`DELETE /v1/document-folders/{folderId}`

Deletes a document folder, as Delete folder does. Its documents are NOT deleted: they become loose (in no folder) and keep their visibility. Undo with POST /changes/{changeId}/revert: it re-creates the folder and files back the documents that are still loose.

**Permissions:** `documents:write` · **Kind:** destructive · **Cost:** 1 unit · MCP tool [`delete_document_folder`](https://api.bymundi.com/docs/mcp/tools/delete_document_folder.md)

Undoable: the response carries `Bymundi-Change-Id`; [revert it](https://api.bymundi.com/docs/guides/undo-and-dry-run.md) with `POST /v1/changes/{changeId}/revert`.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `folderId` | uuid | yes |  |

## Query parameters

_None._

## Response `200`

| Field | Type | Required | Description |
|---|---|---|---|
| `object` | "document_folder" | yes |  |
| `id` | uuid | yes |  |
| `deleted` | true | yes |  |
| `documentsMoved` | integer | yes | Documents that were in it and are now loose — none is ever deleted with a folder. ≥ 0 |

## Errors

Errors are [problem details](https://api.bymundi.com/docs/guides/errors.md). Besides the refusals described above, any call like this one can return:

- [`invalid_request`](https://api.bymundi.com/problems/invalid_request.md) — Invalid request
- [`unauthorized`](https://api.bymundi.com/problems/unauthorized.md) — Missing or invalid API key
- [`insufficient_scope`](https://api.bymundi.com/problems/insufficient_scope.md) — Missing permission
- [`rate_limited`](https://api.bymundi.com/problems/rate_limited.md) — Rate limit reached
- [`not_found`](https://api.bymundi.com/problems/not_found.md) — Not found
- [`idempotency_key_reused`](https://api.bymundi.com/problems/idempotency_key_reused.md) — Idempotency-Key reused
- [`request_in_progress`](https://api.bymundi.com/problems/request_in_progress.md) — Request in progress
- [`forbidden`](https://api.bymundi.com/problems/forbidden.md) — Not allowed

## Examples

#### curl

```bash
curl -X DELETE https://api.bymundi.com/v1/document-folders/$FOLDER_ID \
  -H "Authorization: Bearer $BYMUNDI_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

#### JavaScript

```javascript
const res = await fetch(`https://api.bymundi.com/v1/document-folders/${folderId}`, {
  method: "DELETE",
  headers: {
    Authorization: `Bearer ${process.env.BYMUNDI_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
  },
});
if (!res.ok) throw new Error((await res.json()).detail);
const data = await res.json();
```

#### Python

```python
import os, uuid, requests

res = requests.delete(
    f"https://api.bymundi.com/v1/document-folders/{folderId}",
    headers={"Authorization": f"Bearer {os.environ['BYMUNDI_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
)
res.raise_for_status()
data = res.json()
```
