Skip to content

Latest commit

 

History

History
558 lines (481 loc) · 16.6 KB

File metadata and controls

558 lines (481 loc) · 16.6 KB

Get a List of Templates for Creating Pages landing.demos.getPageList

{% note tip "" %}

If you are developing integrations for Bitrix24 using AI tools (Codex, Claude Code, Cursor), connect to the MCP server so that the assistant can utilize the official REST documentation.

{% endnote %}

Scope: landing

Who can execute the method: a user with View access permission in the Sites section

The method landing.demos.getPageList retrieves a list of file demo templates for pages.

Method Parameters

{% include Note on required parameters %}

#| || Name type | Description || || type^*^ string | Template type.

Possible values:

  • page — templates for pages
  • store — templates for stores
  • knowledge — templates for knowledge bases
  • group — templates for groups
  • mainpage — templates for main pages || || filter object | Object format:
{
    field_1: value_1,
    field_2: value_2,
    ...,
    field_n: value_n
}

where:

  • field_n — filter field
  • value_n — filter value

Filtering is applied to the top-level fields of the template object.

You can filter by fields from the Page Template Type section. Nested fields (e.g., DATA.*) are not considered in the filter || |#

Code Examples

{% include Footnote on examples %}

Example of retrieving a list of page templates, where:

  • type — code of the template set
  • filter — filter by template fields

{% list tabs %}

  • cURL (Webhook)

    curl -X POST \
      -H "Content-Type: application/json" \
      -d '{
        "type": "page",
        "filter": {
          "TYPE": "PAGE"
        }
      }' \
      "https://**put.your-domain-here**/rest/**user_id**/**webhook_code**/landing.demos.getPageList.json"
  • cURL (OAuth)

    curl -X POST \
      -H "Content-Type: application/json" \
      -d '{
        "type": "page",
        "filter": {
          "TYPE": "PAGE"
        },
        "auth": "**put_access_token_here**"
      }' \
      "https://**put.your-domain-here**/rest/landing.demos.getPageList.json"
  • JS (TS)

    // This snippet is an ES module: top-level await requires type="module" or a bundler.
    // $b24 is an already-initialized SDK instance (see the SDK "Get started" guide).
    import { Text } from '@bitrix24/b24jssdk'
    import type { B24Frame } from '@bitrix24/b24jssdk'
    
    declare const $b24: B24Frame
    
    // Shape of the payload returned in result (match the "response handling" section of the page)
    type PageTemplatesResult = Record<string, PageTemplate>
    
    type PageTemplate = {
      ID: string
      XML_ID: string
      TYPE: string[] | string
      TITLE: string
      ACTIVE: boolean
      PUBLICATION: boolean
      LOCK_DELETE: boolean
      AVAILABLE: boolean
      SINGLETON: boolean
      SECTION: string[]
      DESCRIPTION: string
      PREVIEW: string
      PREVIEW2X: string
      PREVIEW3X: string
      APP_CODE: string
      REST: number
      DATA: object
    }
    
    try {
      const response = await $b24.actions.v2.call.make<PageTemplatesResult>({
        method: 'landing.demos.getPageList',
        params: {
          type: 'page',
          filter: {
            TYPE: 'PAGE',
          },
        },
        requestId: Text.getUuidRfc4122()
      })
    
      // The payload is available only on a successful response
      if (!response.isSuccess) {
        console.error(response.getErrorMessages().join('; '))
      } else {
        const result = response.getData()!.result
        console.info('Page templates:', Object.keys(result).length, result)
      }
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  • JS (UMD)

    <!-- Load the SDK (UMD build); it is exposed as the global B24Js -->
    <script src="https://unpkg.com/@bitrix24/b24jssdk@1/dist/umd/index.min.js"></script>
    <script>
      async function getPageList() {
        try {
          // Initialize the SDK inside a Bitrix24 frame
          const $b24 = await B24Js.initializeB24Frame()
    
          const response = await $b24.actions.v2.call.make({
            method: 'landing.demos.getPageList',
            params: {
              type: 'page',
              filter: {
                TYPE: 'PAGE',
              },
            },
            requestId: B24Js.Text.getUuidRfc4122()
          })
    
          // The payload is available only on a successful response
          if (!response.isSuccess) {
            console.error(response.getErrorMessages().join('; '))
            return
          }
    
          const result = response.getData().result
          console.info('Page templates:', Object.keys(result).length, result)
        } catch (error) {
          // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
          console.error(error)
        }
      }
    
      document.addEventListener('DOMContentLoaded', getPageList)
    </script>
  • Python

    from b24pysdk.errors import BitrixAPIError, BitrixSDKException
    
    try:
        bitrix_response = client.landing.demos.get_page_list(
            type="page",
            filter={
                "TYPE": "PAGE",
            },
        ).response
        result = bitrix_response.result
        print(result)
    except BitrixAPIError as error:
        print(
            "Bitrix API error",
            f"error: {error.error}",
            f"error_description: {error.error_description}",
            sep="\n",
        )
    except BitrixSDKException as error:
        print(f"Bitrix SDK error: {error.message}")
    except Exception as error:
        print(f"Unexpected error: {error}")
  • PHP

    try {
        $response = $b24Service
            ->core
            ->call(
                'landing.demos.getPageList',
                [
                    'type' => 'page',
                    'filter' => [
                        'TYPE' => 'PAGE',
                    ],
                ]
            );
    
        $result = $response
            ->getResponseData()
            ->getResult();
    
        echo 'Success: ' . print_r($result, true);
    } catch (Throwable $e) {
        error_log($e->getMessage());
        echo 'Error getting page demo list: ' . $e->getMessage();
    }
  • BX24.js

    BX24.callMethod(
        'landing.demos.getPageList',
        {
            type: 'page',
            filter: {
                TYPE: 'PAGE'
            }
        },
        function(result)
        {
            if (result.error())
            {
                console.error(result.error());
            }
            else
            {
                console.info(result.data());
            }
        }
    );
  • PHP CRest

    require_once('crest.php');
    
    $result = CRest::call(
        'landing.demos.getPageList',
        [
            'type' => 'page',
            'filter' => [
                'TYPE' => 'PAGE',
            ],
        ]
    );
    
    echo '<pre>';
    print_r($result);
    echo '</pre>';
  • Go

    // client and ctx are already created — see the Go SDK section
    res, err := client.Core().Call(ctx, "landing.demos.getPageList", b24.Params{
    	"type": "page",
    	"filter": b24.Params{
    		"TYPE": "PAGE",
    	},
    })
    if err != nil {
    	return fmt.Errorf("landing.demos.getPageList: %w", err)
    }
    
    keys, ok := b24.Keys(res.Result)
    if !ok {
    	return fmt.Errorf("expected an object in the response")
    }
    fmt.Println("fields in response:", len(keys))

{% endlist %}

Response Handling

HTTP Status: 200

{
    "result": {
        "empty": {
            "ID": "empty",
            "XML_ID": "empty",
            "TYPE": ["PAGE", "KNOWLEDGE", "GROUP", "MAINPAGE"],
            "TITLE": "Empty Page",
            "ACTIVE": true,
            "PUBLICATION": false,
            "LOCK_DELETE": false,
            "AVAILABLE": true,
            "SINGLETON": false,
            "SECTION": [],
            "DESCRIPTION": "Create your own website from scratch and attract customers!",
            "PREVIEW": "//bitrix24.com/bitrix/components/bitrix/landing.demo/data/page/empty/preview.jpg",
            "PREVIEW2X": "//bitrix24.com/bitrix/components/bitrix/landing.demo/data/page/empty/preview@2x.jpg",
            "PREVIEW3X": "//bitrix24.com/bitrix/components/bitrix/landing.demo/data/page/empty/preview@3x.jpg",
            "APP_CODE": "",
            "REST": 0,
            "DATA": {
                "name": "Empty Page",
                "active": true,
                "type": ["PAGE", "KNOWLEDGE", "GROUP", "MAINPAGE"],
                "items": [],
                "version": 1,
                "old_id": 402,
                "encoded": true,
                "charset": "UTF-8"
            }
        },
        "search-result": {
            "ID": "search-result",
            "XML_ID": "search-result",
            "TYPE": ["PAGE", "KNOWLEDGE", "GROUP"],
            "TITLE": "Search Results",
            "ACTIVE": false,
            "PUBLICATION": true,
            "SECTION": ["dynamic"],
            "DATA": {
                "code": "search-result",
                "section": ["dynamic"],
                "publication": true,
                "layout": [],
                "items": {
                    "#block3430": {
                        "code": "59.1.search"
                    }
                },
                "encoded": true,
                "charset": "UTF-8"
            }
        }
    },
    "time": {
        "start": 1774625365,
        "finish": 1774625365.92986,
        "duration": 0.9298601150512695,
        "processing": 0,
        "date_start": "2026-03-27T18:29:25+02:00",
        "date_finish": "2026-03-27T18:29:25+02:00",
        "operating_reset_at": 1774625965,
        "operating": 0
    }
}

Returned Data

#| || Name type | Description || || result object | array | Map of page demo templates in the format:

{
    "template_code": page_template
}

where:

  • template_code — template code
  • page_template — page template object more details

If no suitable templates are found, the method returns an empty array result: [] without an error.

The composition of template fields may vary and depends on the specific template || || time time | Information about the execution time of the request || |#

Page Template Type {#page-template}

#| || Name type | Description || || ID string | Template identifier || || XML_ID string | External template code || || TYPE string[] | string | Types for which the template is available.

For file templates, an array is usually returned; for registered application templates — a string || || TITLE string | Template title || || ACTIVE boolean | Active status || || PUBLICATION boolean | Publication availability status || || LOCK_DELETE boolean | Deletion prohibition status || || AVAILABLE boolean | Template availability status || || SINGLETON boolean | Singleton status || || SECTION string[] | Template sections || || DESCRIPTION string | Template description || || PREVIEW string | Preview 1x || || PREVIEW2X string | Preview 2x || || PREVIEW3X string | Preview 3x || || APP_CODE string | Application code || || REST integer | REST template status || || DATA object | array | Template data from file source more details.

For registered application templates, an empty array may be returned || |#

Template DATA Structure {#page-template-data}

#| || Name type | Description || || code string | Template code in export data || || name string | Template name in export data || || type string[] | Template types.

Possible values:

  • page — templates for pages
  • store — templates for stores
  • knowledge — templates for knowledge bases
  • group — templates for groups
  • mainpage — templates for main pages || || description string | null | Template description || || active boolean | Template active status in export data || || publication boolean | Template publication status in export data || || singleton boolean | Template singleton status in export data || || lock_delete boolean | Deletion prohibition status in export data || || preview string | Preview 1x in export data || || preview2x string | Preview 2x in export data || || preview3x string | Preview 3x in export data || || preview_url string | Preview link in export data || || show_in_list string | Show in list status (Y/N) || || sort integer | Template sorting index || || section string[] | Template sections in export data || || parent string | Parent template/site code || || disable_import string | Import prohibition flag in template data (e.g., Y) || || is_webform_page string | CRM form page flag (e.g., Y) || || fields object | Template fields more details.

Codes for fields.ADDITIONAL_FIELDS can be found in the Additional Page Fields section || || items array | object | Template composition more details || || layout array | object | Template layout data more details || || folders array | object | Template folders more details || || syspages array | object | Template system pages more details || || master_pages array | List of template master pages more details || || version integer | Data format version || || old_id integer | string | Original identifier (may come as a number or string depending on the template) || || encoded boolean | Added by the method with a value of true if the DATA contains the items field || || charset string | Added by the method with a value of UTF-8 if the DATA contains the items field || |#

Error Handling

HTTP Status: 400

{
    "error": "ERROR_ARGUMENT",
    "error_description": "The value of an argument 'filter' has an invalid type",
    "argument": "filter"
}

{% include notitle error handling %}

Possible Error Codes

#| || Code | Description | Value || || ERROR_ARGUMENT | The value of an argument 'filter' has an invalid type | The filter parameter is passed in an incorrect type || || MISSING_PARAMS | Insufficient call parameters | The required parameter type is missing || || ACCESS_DENIED | Insufficient permissions | The user did not pass the general access checks for the Landing module || || TYPE_ERROR | Data type error | Method call with incorrect parameter types || || SYSTEM_ERROR | Internal error | Error executing the method on the server side || |#

{% include system errors %}

Continue Learning