# crm.documentgenerator.template.list

URL: https://chugunov.pro/api-bitrix24/crm/document-generator/templates/crm-document-generator-template-list/
Проверено на Битрикс24 REST API, обновлено 11.09.2026 (ревизия источника fb39d6c).
Источник: официальная документация Битрикс24 (bitrix-tools/b24-rest-docs, лицензия MIT, © Bitrix). Справочник независимый, официальной документацией не является.

Получить список шаблонов документов
Scope: `crm`
Кто может выполнять метод: пользователь с правом "изменения" шаблонов генератора документов

## Описание

Метод `crm.documentgenerator.template.list` возвращает список шаблонов документов.

## Параметры

- `select` `array` — необязательный. Список полей, которые нужно вернуть у шаблонов.
  При выборке можно использовать:
  - `'*'` — для выборки всех стандартных полей шаблона
  - явный список полей, например `["id","name","region","active"]`
  Дополнительно поддерживаются:
  - `entityTypeId` — массив привязок шаблона к CRM-объектам
  - `users` — массив кодов прав доступа
  Основные поля для `select`: `id`, `name`, `region`, `code`, `active`, `moduleId`, `numeratorId`, `withStamps`, `isDeleted`, `sort`, `createTime`, `updateTime`
  Список полей шаблона смотрите в разделе [`Тип template`](#template). По умолчанию используется `["*"]`
- `filter` `object` — необязательный. Объект формата:
  ```
  {
      field_1: value_1,
      field_2: value_2,
      ...,
      field_n: value_n
  }
  ```
  где:
  - `field_n` — название поля для фильтрации
  - `value_n` — значение фильтра
  К ключам `field_n` можно добавлять префиксы:
  - `>=` — больше либо равно
  - `>` — больше
  - `<=` — меньше либо равно
  - `<` — меньше
  - `@` — IN, в значении передается массив
  - `!@` — NOT IN, в значении передается массив
  - `=` — равно (по умолчанию)
  - `!=` или `!` — не равно
  Особенности:
  - если `isDeleted` не передан, применяется фильтр `isDeleted = "N"`
  - фильтр `moduleId` принудительно ограничивается значением `crm`
  - можно фильтровать по `entityTypeId`, например `["2","2_category_37"]`
  Основные поля для `filter`: `id`, `name`, `region`, `code`, `active`, `moduleId`, `numeratorId`, `withStamps`, `isDeleted`, `sort`, `createTime`, `updateTime`, `entityTypeId`
- `order` `object` — необязательный. Объект формата:
  ```
  {
      field_1: value_1,
      field_2: value_2,
      ...,
      field_n: value_n
  }
  ```
  где:
  - `field_n` — название поля сортировки
  - `value_n` — направление сортировки: `ASC` или `DESC`
  Основные поля для `order`: `id`, `name`, `region`, `code`, `active`, `moduleId`, `numeratorId`, `withStamps`, `isDeleted`, `sort`, `createTime`, `updateTime`
  Пример: `{"id":"DESC","sort":"ASC"}`
- `start` `integer` — необязательный. Параметр постраничной навигации.
  Размер страницы фиксирован: `50` записей.
  Формула для получения N-й страницы:
  `start = (N - 1) * 50`
  Подробнее в статье [Особенности списочных методов](https://apidocs.bitrix24.ru/settings/how-to-call-rest-api/list-methods-pecularities.html)

## Ответ

HTTP-статус: 200

```json
{
    "result": {
        "templates": {
            "39": {
                "id": "39",
                "name": "Демонстрационная реализация товара",
                "region": "ru",
                "download": "https://mysite.ru/bitrix/services/main/ajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=39",
                "users": [
                    "UA"
                ],
                "entityTypeId": [
                    "2_category_0",
                    "2_category_32"
                ],
                "downloadMachine": "https://mysite.ru/rest/crm.documentgenerator.template.download.json?auth=***&token=***"
            },
            "37": {
                "id": "37",
                "name": "Акт о списании товаров (Россия)",
                "region": "ru",
                "download": "https://mysite.ru/bitrix/services/main/ajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=37",
                "users": [
                    "UA"
                ],
                "entityTypeId": [
                    "2_category_37",
                    "bitrix\\crm\\integration\\documentgenerator\\dataprovider\\storedocumentdeduct"
                ],
                "downloadMachine": "https://mysite.ru/rest/crm.documentgenerator.template.download.json?auth=***&token=***"
            }
        }
    },
    "total": 20,
    "time": {
        "start": 1773845479,
        "finish": 1773845479.829607,
        "duration": 0.8296070098876953,
        "processing": 0,
        "date_start": "2026-03-18T17:51:19+03:00",
        "date_finish": "2026-03-18T17:51:19+03:00",
        "operating_reset_at": 1773846079,
        "operating": 0
    }
}
```

### Возвращаемые данные

- `result` `object`. Корневой элемент ответа. Содержит объект [`templates`](#templates)
- `total` `integer`. Общее количество шаблонов, подходящих под фильтр
- `time` `time`. Информация о времени выполнения запроса

## Ошибки

HTTP-статус: 400

```json
{
    "error": "DOCGEN_ACCESS_ERROR",
    "error_description": "Access denied"
}
```

- `DOCGEN_ACCESS_ERROR` — Access denied. Нет доступа к шаблонам
- — — You do not have permissions to modify templates. Недостаточно прав для изменения шаблонов генератора документов
- — — Module documentgenerator is not installed. Модуль `documentgenerator` недоступен

## Примеры запроса

### cURL (Webhook)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"select":["id","name","region","entityTypeId","users"],"order":{"id":"desc"},"filter":{"region":"ru","active":"Y"},"start":0}' \
https://**put_your_bitrix24_address**/rest/**put_your_user_id_here**/**put_your_webhook_here**/crm.documentgenerator.template.list
```

### cURL (OAuth)

```bash
curl -X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"select":["id","name","region","entityTypeId","users"],"order":{"id":"desc"},"filter":{"region":"ru","active":"Y"},"start":0,"auth":"**put_access_token_here**"}' \
https://**put_your_bitrix24_address**/rest/crm.documentgenerator.template.list
```

### JS (TS)

```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

type Template = {
  id: string
  name: string
  region: string
  download: string
  users: string[]
  entityTypeId: string[]
  downloadMachine: string
}

// Shape of the payload returned in result (match the "response handling" section of the page)
type TemplatesResult = {
  templates: Record<string, Template>
}

try {
  // crm.documentgenerator.template.list returns a single page (max 50 records). For the whole result set
  // use a list helper: $b24.actions.v2.callList.make() returns every record as one
  // array, $b24.actions.v2.fetchList.make() yields them in chunks (async generator).
  // NOTE: the list helpers do not accept `order` (it is excluded from their params, so
  // passing it is a TS error) — keep this call.make + `start` variant when sort matters.
  const response = await $b24.actions.v2.call.make<TemplatesResult>({
    method: 'crm.documentgenerator.template.list',
    params: {
      select: ['id', 'name', 'region', 'entityTypeId', 'users'],
      order: { id: 'desc' },
      filter: { region: 'ru', active: 'Y' },
      start: 0,
    },
    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('Templates on this page:', Object.keys(result.templates).length)
    console.info(result.templates)
  }
} catch (error) {
  // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
  console.error(error)
}
```

### JS (UMD)

```html
<!-- 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 fetchTemplateList() {
    try {
      // Initialize the SDK inside a Bitrix24 frame
      const $b24 = await B24Js.initializeB24Frame()

      // crm.documentgenerator.template.list returns a single page (max 50 records). For the whole result set
      // use a list helper: $b24.actions.v2.callList.make() returns every record as one
      // array, $b24.actions.v2.fetchList.make() yields them in chunks (async generator).
      // NOTE: the list helpers do not accept `order` (it is excluded from their params, so
      // passing it is a TS error) — keep this call.make + `start` variant when sort matters.
      const response = await $b24.actions.v2.call.make({
        method: 'crm.documentgenerator.template.list',
        params: {
          select: ['id', 'name', 'region', 'entityTypeId', 'users'],
          order: { id: 'desc' },
          filter: { region: 'ru', active: 'Y' },
          start: 0,
        },
        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('Templates on this page:', Object.keys(result.templates).length)
      console.info(result.templates)
    } catch (error) {
      // Thrown on transport or SDK failures (AjaxError, SdkError, etc.)
      console.error(error)
    }
  }

  document.addEventListener('DOMContentLoaded', fetchTemplateList)
</script>
```

### Python

```python
from b24pysdk.errors import BitrixAPIError, BitrixSDKException

try:
    bitrix_response = client.crm.documentgenerator.template.list(
        select=[
            "id",
            "name",
            "region",
            "entityTypeId",
            "users",
        ],
        order={
            "id": "desc",
        },
        filter={
            "region": "ru",
            "active": "Y",
        },
        start=0,
    ).response
    result = bitrix_response.result
    print(result)
except BitrixAPIError as error:
    print(
        "Ошибка Bitrix API",
        f"error: {error.error}",
        f"error_description: {error.error_description}",
        sep="\n",
    )
except BitrixSDKException as error:
    print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
    print(f"Непредвиденная ошибка: {error}")

from b24pysdk.errors import BitrixAPIError, BitrixSDKException

try:
    bitrix_response = client.crm.documentgenerator.template.list(
        select=[
            "id",
            "name",
            "region",
            "entityTypeId",
            "users",
        ],
        order={
            "id": "desc",
        },
        filter={
            "region": "ru",
            "active": "Y",
        },
    ).as_list().response
    result = bitrix_response.result
    for item in result:
        print(item)
except BitrixAPIError as error:
    print(
        "Ошибка Bitrix API",
        f"error: {error.error}",
        f"error_description: {error.error_description}",
        sep="\n",
    )
except BitrixSDKException as error:
    print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
    print(f"Непредвиденная ошибка: {error}")

from b24pysdk.errors import BitrixAPIError, BitrixSDKException

try:
    bitrix_response = client.crm.documentgenerator.template.list(
        select=[
            "id",
            "name",
            "region",
            "entityTypeId",
            "users",
        ],
        order={
            "id": "desc",
        },
        filter={
            "region": "ru",
            "active": "Y",
        },
    ).as_list_fast(descending=True).response
    result = bitrix_response.result
    for item in result:
        print(item)
except BitrixAPIError as error:
    print(
        "Ошибка Bitrix API",
        f"error: {error.error}",
        f"error_description: {error.error_description}",
        sep="\n",
    )
except BitrixSDKException as error:
    print(f"Ошибка Bitrix SDK: {error.message}")
except Exception as error:
    print(f"Непредвиденная ошибка: {error}")
```

### PHP

```php
try {
    $response = $b24Service
        ->core
        ->call(
            'crm.documentgenerator.template.list',
            [
                'select' => ['id', 'name', 'region', 'entityTypeId', 'users'],
                'order' => ['id' => 'desc'],
                'filter' => ['region' => 'ru', 'active' => 'Y'],
                'start' => 0,
            ]
        );

    $result = $response
        ->getResponseData()
        ->getResult();

    echo '<pre>';
    print_r($result);
    echo '</pre>';

} catch (Throwable $e) {
    error_log($e->getMessage());
    echo 'Error getting templates list: ' . $e->getMessage();
}
```

### BX24.js

```js
BX24.callMethod(
    'crm.documentgenerator.template.list',
    {
        select: ['id', 'name', 'region', 'entityTypeId', 'users'],
        order: { id: 'desc' },
        filter: { region: 'ru', active: 'Y' },
    },
    (result) => {
        if (result.error()) {
            console.error(result.error());
            return;
        }

        console.info(result.data());

        if (result.more()) {
            result.next();
        }
    },
);
```

### PHP CRest

```php
require_once('crest.php');

$result = CRest::call(
    'crm.documentgenerator.template.list',
    [
        'select' => ['id', 'name', 'region', 'entityTypeId', 'users'],
        'order' => ['id' => 'desc'],
        'filter' => ['region' => 'ru', 'active' => 'Y'],
        'start' => 0,
    ]
);

echo '<PRE>';
print_r($result);
echo '</PRE>';
```

### Go

```go
// client и ctx уже созданы — см. раздел «SDK для Go»
res, err := client.Core().Call(ctx, "crm.documentgenerator.template.list", b24.Params{
	"select": []string{"id", "name", "region", "entityTypeId", "users"},
	"order": b24.Params{
		"id": "desc",
	},
	"filter": b24.Params{
		"region": "ru",
		"active": "Y",
	},
	"start": 0,
}, b24.WithIdempotent())
if err != nil {
	return fmt.Errorf("crm.documentgenerator.template.list: %w", err)
}

// Метод заворачивает ответ в объект с ключом "templates".
raw, ok := b24.Unwrap(res.Result, "templates")
if !ok {
	return fmt.Errorf("в ответе нет ключа templates")
}

fmt.Printf("%s\n", raw)
```

Оригинал в официальной документации: https://apidocs.bitrix24.ru/api-reference/crm/document-generator/templates/crm-document-generator-template-list.html
