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

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

Create from a template

POST /v1/pages/from-template

Creates a page on a site from a ready-made template, at the site root or in the specified folder. The site and the destination folder are checked before the page is created.

Requires the landing scope.

Parameters

Parameter Type Required Description
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
FieldsiteId Typenumber Requiredyes DescriptionSite ID. List: GET /v1/sites
FieldtemplateCode Typestring Requiredyes DescriptionTemplate code — the code field. List: GET /v1/page-templates
Fieldtitle Typestring Requiredno DescriptionPage title. Without the field the page gets the template name, for example "Empty page" for the empty template
Fielddescription Typestring Requiredno DescriptionPage description
FieldfolderId Typenumber | null Requiredno DescriptionID of a folder on the siteId site. List: GET /v1/sites/:id/folders. null or 0 — site root

Examples

curl — personal key

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/pages/from-template" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"siteId": 3, "templateCode": "empty", "title": "Page from a template"}'

curl — OAuth application

Terminal
curl -X POST "https://vibecode.bitrix24.com/v1/pages/from-template" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"siteId": 3, "templateCode": "empty", "title": "Page from a template"}'

JavaScript — personal key

javascript
const response = await fetch("https://vibecode.bitrix24.com/v1/pages/from-template", {
  method: "POST",
  headers: {"X-Api-Key": "YOUR_API_KEY", "Content-Type": "application/json"},
  body: JSON.stringify({"siteId": 3, "templateCode": "empty", "title": "Page from a template"}),
})
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/from-template", {
  method: "POST",
  headers: {"X-Api-Key": "YOUR_APP_KEY", "Authorization": "Bearer USER_SESSION_TOKEN", "Content-Type": "application/json"},
  body: JSON.stringify({"siteId": 3, "templateCode": "empty", "title": "Page from a template"}),
})
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
Fielddata Typeobject DescriptionThe created page
Fielddata.id Typenumber DescriptionPage ID
Fielddata.siteId Typenumber DescriptionID of the page's site
Fielddata.folderId Typenumber | null DescriptionFolder ID. null — the page is at the site root
Fielddata.title Typestring DescriptionPage title
Fielddata.code Typestring DescriptionPage code in the URL
Fielddata.active Typeboolean DescriptionWhether the page is published
Fielddata.deleted Typestring DescriptionY — the page is in the trash, N — it is not

Response example

The page is created, HTTP status 201 Created:

JSON
{
  "success": true,
  "data": {
    "id": 2431,
    "siteId": 3,
    "folderId": null,
    "title": "Page from a template",
    "code": "page-from-a-template",
    "active": false,
    "deleted": "N"
  }
}

Error response example

404 — no template with this code:

JSON
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "Template not found; read GET /v1/page-templates for templateCode values."
  }
}

Errors

HTTP Code Description
HTTP404 CodeENTITY_NOT_FOUND DescriptionTemplate not found; read GET /v1/page-templates for templateCode values. — template templateCode does not exist
HTTP404 CodeENTITY_NOT_FOUND DescriptionSite not found. — site siteId does not exist
HTTP404 CodeENTITY_NOT_FOUND DescriptionFolder not found in the destination site. — the folderId folder is not on the siteId site
HTTP404 CodeENTITY_NOT_FOUND DescriptionPage or folder not found. — Bitrix24 did not find the page or folder during creation
HTTP400 CodeMISSING_REQUIRED_FIELDS DescriptionsiteId and templateCode are required; read GET /v1/page-templates for codes. — siteId or templateCode is not passed, or templateCode is an empty string or not a string
HTTP400 CodeINVALID_PARAMS DescriptionBody must be a JSON object. — the body is not a JSON object
HTTP400 CodeINVALID_PARAMS DescriptionBody contains a field this operation does not accept. — the body contains a field that is not in the request fields table
HTTP400 CodeINVALID_PARAMS DescriptionsiteId must be a positive safe integer. — siteId is not a positive integer
HTTP400 CodeINVALID_PARAMS DescriptionfolderId must be a positive safe integer or null for the root. — folderId is not a positive integer, null or 0
HTTP400 CodeINVALID_PARAMS Descriptiontitle must be a string. — title is not a string
HTTP400 CodeINVALID_PARAMS Descriptiondescription must be a string. — description is not a string
HTTP400 CodeINVALID_SCOPE Descriptionscope must be KNOWLEDGE, GROUP or MAINPAGE, or omitted. — scope is not KNOWLEDGE, GROUP or MAINPAGE
HTTP422 CodeBITRIX_NO_EFFECT DescriptionBitrix24 did not confirm the page action. — Bitrix24 did not return the ID of the created page
HTTP422 CodeBITRIX_NO_EFFECT DescriptionBitrix24 did not return the page after the action. — the created page could not be read
HTTP422 CodeBITRIX_NO_EFFECT DescriptionBitrix24 did not persist the requested page state. — the page ended up outside the siteId site or outside the folderId folder
HTTP422 CodeBITRIX_ERROR DescriptionBitrix24 rejected the creation. The error text comes from Bitrix24
HTTP403 CodeSCOPE_DENIED DescriptionThe API key lacks the landing scope
HTTP403 CodeBITRIX_ACCESS_DENIED DescriptionThe Bitrix24 user on whose behalf the key was issued has no permission to create the page
HTTP403 CodeWRITE_BLOCKED_READONLY_KEY DescriptionThe key works in read-only mode. The request is rejected before it reaches Bitrix24
HTTP401 CodeTOKEN_MISSING DescriptionThe API key has no configured tokens
HTTP401 CodeMISSING_API_KEY DescriptionThe X-Api-Key header is not passed
HTTP401 CodeINVALID_API_KEY DescriptionThe key in X-Api-Key is not found or has been revoked
HTTP409 CodeLANDING_MODULE_NOT_ENABLED DescriptionThe Sites module is not available on the Bitrix24 account
HTTP409 CodePORTAL_ADDRESS_CHANGED DescriptionThe on-premise 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 or responded with a server error
HTTP503 CodeBITRIX_TIMEOUT DescriptionBitrix24 did not respond within the allotted time

Full list of common API errors — Errors.

See also