## Move a folder to the trash

`POST /v1/sites/:id/folders/:folderId/trash`

Moves the folder to the trash together with its pages.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Site ID — a positive integer. List: [`GET /v1/sites`](/docs/entities/sites/list) |
| `folderId` (path) | number | yes | ID of a folder on this site. List: [`GET /v1/sites/:id/folders`](/docs/entities/sites/folders/list) |
| `scope` (query) | string | no | Internal landing scope: `KNOWLEDGE` / `GROUP` / `MAINPAGE`. Specify it if the site belongs to the corresponding scope. Otherwise `404 ENTITY_NOT_FOUND` is returned |

The request body is empty or `{}`. Any field in the body is rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/sites/233/folders/117/trash" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/sites/233/folders/117/trash" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/233/folders/117/trash', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log('In the trash:', data.deleted)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/sites/233/folders/117/trash', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | `true` on success |
| `data.id` | number | Folder ID |
| `data.parentId` | number \| null | Parent folder ID. `null` — the folder is in the site root |
| `data.siteId` | number | Site ID. List: [`GET /v1/sites`](/docs/entities/sites/list) |
| `data.indexPageId` | number \| null | ID of the folder's index page — a page from [`GET /v1/pages`](/docs/entities/pages/list). `null` if not assigned |
| `data.active` | boolean | Whether the folder is published |
| `data.deleted` | boolean | Whether the folder is in the trash |
| `data.title` | string | Folder name |
| `data.code` | string | Folder code — the URL segment of its pages |
| `data.createdById` | number \| null | ID of the user who created the folder. List: [`GET /v1/users`](/docs/entities/users/list) |
| `data.modifiedById` | number \| null | ID of the user who last modified the folder. List: [`GET /v1/users`](/docs/entities/users/list) |
| `data.dateCreate` | string \| null | Creation date in ISO 8601 format without a time zone: Bitrix24 account time, `2026-10-16T15:49:43` |
| `data.dateModify` | string \| null | Last modification date in the same format |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 117,
    "parentId": null,
    "siteId": 233,
    "indexPageId": null,
    "active": true,
    "deleted": true,
    "title": "Docs test catalog",
    "code": "catalog",
    "createdById": 1317,
    "modifiedById": 1317,
    "dateCreate": "2026-10-16T15:49:43",
    "dateModify": "2026-10-16T15:50:42"
  }
}
```

## Error response example

404 — folder not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Folder not found in this site or not visible"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `id` or `folderId` is not a positive integer |
| 400 | `INVALID_SCOPE` | `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 400 | `INVALID_PARAMS` | A request body was passed. The method accepts an empty body or `{}` |
| 404 | `ENTITY_NOT_FOUND` | No site with this `id` exists, it is not accessible to the key's user, or it belongs to a different `scope` |
| 404 | `ENTITY_NOT_FOUND` | No folder with this `folderId` exists on this site, or it is not accessible |
| 404 | `ENTITY_NOT_FOUND` | The folder was not found after the operation — a concurrent request moved or deleted it |
| 422 | `BITRIX_ERROR` | Bitrix24 did not confirm the folder operation or rejected it. The reason is in `message` |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is unavailable on this Bitrix24 account. Ask a Bitrix24 account administrator to enable it — until then a retry returns the same refusal |
| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied access: the key's user has no permissions for this site and no administrator rights, or the feature is unavailable on the Bitrix24 account |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The API key is read-only |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

- **The folder's publication is kept.** A published folder keeps `active: true` in the trash too. It can be unpublished only after [restoring](/docs/entities/sites/folders/restore) it: for a folder in the trash, [`POST /v1/sites/:id/folders/:folderId/unpublish`](/docs/entities/sites/folders/unpublish) responds with `422 BITRIX_ERROR`.
- **Nested folders are not moved to the trash.** They keep `deleted: false` and are visible in [`GET /v1/sites/:id/folders`](/docs/entities/sites/folders/list) without a filter. While the parent folder is in the trash, unpublishing a nested folder and publishing an unpublished nested folder both respond with `422 BITRIX_ERROR`.
- **The folder's pages become unavailable.** [`GET /v1/pages/:id`](/docs/entities/pages/get) returns `404` for such a page. After the [folder is restored](/docs/entities/sites/folders/restore), its pages come back unpublished.
- **Moving to the trash again succeeds without an error.** For a folder that is already in the trash the response is `200`, and the folder stays in the trash.

## See also

- [Restore a folder](/docs/entities/sites/folders/restore)
- [List folders](/docs/entities/sites/folders/list)
- [Unpublish a folder](/docs/entities/sites/folders/unpublish)
