## Move to trash

`POST /v1/pages/:id/trash`

Moves a page to trash and unpublishes it.

Requires the `landing` scope.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `id` (path) | number | yes | Page ID. List: [`GET /v1/pages`](/docs/entities/pages/list) |
| `scope` (query) | string | no | Site type: `KNOWLEDGE` — knowledge base, `GROUP` — workgroup site, `MAINPAGE` — main page. Omit the parameter for pages of all other sites |

The body is empty or `{}`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pages/2427/trash" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pages/2427/trash" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### JavaScript — personal key

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/2427/trash", {
  method: "POST",
  headers: {"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
  body: JSON.stringify({}),
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)
```

### JavaScript — OAuth application

```javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/2427/trash", {
  method: "POST",
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json"},
  body: JSON.stringify({}),
})
const result = await response.json()
if (!response.ok) throw new Error(result.error.message)
console.log(result.data)
```

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | Always `true` on success |
| `data` | object | The page after the action |
| `data.id` | number | Page ID |
| `data.siteId` | number | ID of the page's site |
| `data.folderId` | number \| null | Folder ID. `null` — the page is at the site root |
| `data.title` | string | Page title |
| `data.code` | string | Page code in the URL |
| `data.active` | boolean | Whether the page is published |
| `data.deleted` | string | `Y` — the page is in trash, `N` — it is not |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 2427,
    "siteId": 3,
    "folderId": null,
    "title": "Empty page",
    "code": "empty-page",
    "active": false,
    "deleted": "Y"
  }
}
```

## Error response example

404 — no page with this `id` exists:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Page not found."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 404 | `ENTITY_NOT_FOUND` | `Page not found.` — no page with this `id` exists |
| 404 | `ENTITY_NOT_FOUND` | `Page or folder not found.` — Bitrix24 did not find the page or folder while performing the action |
| 400 | `INVALID_PAGE_ID` | `id must be a positive safe integer.` — `id` is not a positive integer |
| 400 | `INVALID_PARAMS` | `Body must be a JSON object.` — the body is not a JSON object |
| 400 | `INVALID_PARAMS` | `Body contains a field this operation does not accept.` — the body contains a field, but it must be empty or `{}` |
| 400 | `INVALID_SCOPE` | `scope must be KNOWLEDGE, GROUP or MAINPAGE, or omitted.` — `scope` is not `KNOWLEDGE`, `GROUP` or `MAINPAGE` |
| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not confirm the page action.` — Bitrix24 did not confirm the action |
| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not return the page after the action.` — the page could not be read after the action |
| 422 | `BITRIX_NO_EFFECT` | `Bitrix24 did not persist the requested page state.` — after the action the page is not in trash |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the action, for example, for an include area. The error text comes from Bitrix24 |
| 403 | `SCOPE_DENIED` | The API key does not have the `landing` scope |
| 403 | `BITRIX_ACCESS_DENIED` | The Bitrix24 user on whose behalf the key was issued has no permission to perform the action on the page |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key works in read-only mode; the request is rejected before it reaches Bitrix24 |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `INVALID_API_KEY` | The key in `X-Api-Key` is not found or has been revoked |
| 409 | `PORTAL_ADDRESS_CHANGED` | The on-premise Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook |
| 429 | `RATE_LIMITED` | The Bitrix24 request limit is exceeded. Retry the request in 1-2 seconds |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 did not respond or responded with a server error |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time |

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

## Known specifics

- **A repeated call returns no error.** For a page that is already in trash, the response is `200` with its current state.

## See also

- [Restore a page](/docs/entities/pages/restore)
- [Delete a page](/docs/entities/pages/delete)
- [Pages](/docs/entities/pages)
