لوكلاء AI: ملف markdown لهذه الصفحة — /docs-content-en/entities/pages/blocks/copy.md فهرس التوثيق — /llms.txt

مقالات التوثيق متاحة حاليًا باللغة الإنجليزية فقط.

Copy a block

POST /v1/pages/:pageId/blocks/:blockId/copy

Creates a copy of a block on the same page or on another page, leaving the source block unchanged. The copy gets a new ID.

Parameters

Parameter Type Required Description
ParameterpageId (path) Typenumber Requiredyes DescriptionPage ID. List: GET /v1/pages
ParameterblockId (path) Typenumber Requiredyes DescriptionID of a block in the draft of page pageId. List: GET /v1/pages/:pageId/blocks without the version parameter. For a block from another page, a block in the trash or an ID from the published version, the response is 404
Parameterscope (query) Typestring Requiredno DescriptionSite type: KNOWLEDGE — knowledge base, GROUP — workgroup site, MAINPAGE — main page. Omit the parameter for pages of other sites

Request fields (body)

Field Type Required Description
FieldtoPageId Typenumber Requiredno DescriptionID of the page that receives the copy. List: GET /v1/pages. Without the field, the copy is placed on page pageId
FieldafterBlockId Typenumber Requiredno DescriptionID of the block on page toPageId, or on page pageId when toPageId is omitted, after which the copy is placed. List: GET /v1/pages/:pageId/blocks. Without the field, the copy is placed last on the page

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/pages/2417/blocks/29451/copy" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/pages/2417/blocks/29451/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/2417/blocks/29451/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/2417/blocks/29451/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
Fieldsuccess Typeboolean DescriptionAlways true on success. The HTTP status of the response is 201 Created
Fielddata.blockId Typenumber DescriptionID of the block copy
Fielddata.pageId Typenumber DescriptionID of the page that holds the copy

Response example

JSON
{
  "success": true,
  "data": {
    "blockId": 29459,
    "pageId": 2417
  }
}

Error response example

400 — block afterBlockId is not on page toPageId:

JSON
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "afterBlockId must belong to the destination page."
  }
}

Errors

HTTP Code Description
HTTP400 CodeINVALID_PARAMS DescriptionDestination ids must be positive safe integers. — toPageId or afterBlockId is not a positive integer
HTTP400 CodeINVALID_PARAMS DescriptionafterBlockId must belong to the destination page. — block afterBlockId is not on the page that receives the block
HTTP400 CodeINVALID_PARAMS DescriptionPath ids must be positive safe integers. — pageId or blockId is not a positive integer
HTTP400 CodeINVALID_PARAMS DescriptionBody must be a JSON object. — the body is not a JSON object
HTTP400 CodeINVALID_PARAMS DescriptionUnsupported body field. — the body contains a field that is not in the Request fields (body) table
HTTP400 CodeFST_ERR_CTP_EMPTY_JSON_BODY DescriptionThe Content-Type: application/json header is sent with an empty body. Send a {} body or drop the header
HTTP400 CodeINVALID_SCOPE Descriptionscope must be KNOWLEDGE, GROUP or MAINPAGE, or omitted. — scope is not KNOWLEDGE, GROUP or MAINPAGE
HTTP404 CodeENTITY_NOT_FOUND DescriptionBlocks not found on this page. — the block is not in the draft of page pageId: it belongs to another page, is in the trash, was deleted, the ID comes from the published version, or page pageId does not exist. The IDs of such blocks are listed in error.blockIds
HTTP404 CodeENTITY_NOT_FOUND DescriptionPage or block not found. — page toPageId does not exist
HTTP422 CodeBITRIX_NO_EFFECT DescriptionBitrix24 returned an invalid block descriptor; the action cannot be confirmed. — Bitrix24 returned a block descriptor that could not be parsed
HTTP422 CodeBITRIX_NO_EFFECT DescriptionBitrix24 did not return the expected block id. — Bitrix24 did not return the ID of the copy
HTTP422 CodeBITRIX_NO_EFFECT DescriptionBlock destination could not be confirmed. — after the write, the copy was not found on page toPageId
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 rejected the action. The error text comes from Bitrix24
HTTP403 CodeSCOPE_DENIED DescriptionThe API key does not have the landing scope
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key is read-only. The request is rejected before Bitrix24 is called
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe Bitrix24 user the key is issued for has no permission to edit the page
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is missing
HTTP401 CodeINVALID_API_KEY DescriptionThe key in X-Api-Key is not found or has been revoked
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no configured tokens
HTTP409 CodeLANDING_MODULE_NOT_ENABLED DescriptionThe Sites module is not available on the Bitrix24 account
HTTP409 CodePORTAL_ADDRESS_CHANGED DescriptionA self-hosted Bitrix24 moved to a new address, but the key's webhook was issued for the old one. Reissue the key's webhook
HTTP429 CodeRATE_LIMITED DescriptionThe Bitrix24 request limit is exceeded. Retry the request in 1-2 seconds
HTTP502 CodeBITRIX_UNAVAILABLE DescriptionBitrix24 did not respond, returned a server error, or sent a response larger than 8 MiB
HTTP503 CodeBITRIX_TIMEOUT DescriptionBitrix24 did not respond in time

Full list of common API errors — Errors.

Known specifics

  • The copy inherits visibility. A copy of a hidden block is hidden too. To show it, call POST /v1/pages/:pageId/blocks/:blockId/show.
  • A failure after the write does not cancel the copy. Responses 422 BITRIX_NO_EFFECT, 429, 502 and 503 do not mean that no copy was created, and a retry creates another copy. Before retrying, re-read the page blocks with GET /v1/pages/:pageId/blocks.
  • The call changes the draft of the page that holds the copy. Site visitors see the change after the page is published with POST /v1/pages/:id/publication. See Pages for details.

See also