## Copy a page

`POST /v1/pages/:id/copy`

Creates a copy of a page together with its blocks. A page in the trash can be copied too. A copy of an active page may be published right away, subject to the plan limits. The destination folder is checked before the copy is created.

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 |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `toSiteId` | number | no | Target site ID. List: [`GET /v1/sites`](/docs/entities/sites/list) |
| `toFolderId` | number \| null | no | Folder ID on the target site, or on the page's own site when `toSiteId` is omitted. List: [`GET /v1/sites/:id/folders`](/docs/entities/sites/folders/list). `null` or `0` — site root |
| `skipSystem` | boolean | no | Do not copy the system page flag. Defaults to `false` |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/pages/2427/copy" \
  -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/copy" \
  -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/copy", {
  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/copy", {
  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 in 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 the trash, `N` — it is not |

## Response example

Copy created, HTTP status `201 Created`:

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

## Error response example

404 — no page with this `id`:

```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` |
| 404 | `ENTITY_NOT_FOUND` | `Site not found.` — site `toSiteId` does not exist |
| 404 | `ENTITY_NOT_FOUND` | `Folder not found in the destination site.` — folder `toFolderId` does not exist on the target site |
| 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 that is not in the request fields table |
| 400 | `INVALID_PARAMS` | `toSiteId must be a positive safe integer.` — `toSiteId` is not a positive integer |
| 400 | `INVALID_PARAMS` | `toFolderId must be a positive safe integer or null for the root.` — `toFolderId` is not a positive integer, `null` or `0` |
| 400 | `INVALID_PARAMS` | `skipSystem must be boolean.` — `skipSystem` is not `true` or `false` |
| 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.` — the copy did not end up on the target site or in the target folder |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the action. 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 the key was issued for has no permission for the page action |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only. The request is refused before any call to 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` was not found or has been revoked |
| 409 | `LANDING_MODULE_NOT_ENABLED` | The Sites module is unavailable on the Bitrix24 account. Returned when the body contains `toSiteId` |
| 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 rate limit was exceeded. Retry the request in 1-2 seconds |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 did not respond or returned a server error |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond within the allotted time |

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

## See also

- [Move a page](/docs/entities/pages/move)
- [List folders](/docs/entities/sites/folders/list)
- [Get a page](/docs/entities/pages/get)
- [Pages](/docs/entities/pages)
