
## List templates

`GET /v1/doc-templates`

Returns the list of the Bitrix24 account's document templates with support for filtering, field selection, sorting, and pagination.

## Parameters

| Parameter | Type | Default | Description |
|----------|-----|-----------|---------|
| `filter` | object | — | Filter by template fields. Field list — `GET /v1/doc-templates/fields`.<br>[Filtering syntax](/docs/filtering). Example: `?filter[active]=Y` |
| `select` | string | — | Field selection: `?select=id,name,region` |
| `order` | object | — | Sort by field: `?order[sort]=asc` |
| `limit` | number | `50` | Number of records (up to 5000) |
| `offset` | number | `0` | Offset for pagination |

For `limit > 50`, Vibecode automatically requests several pages from Bitrix24 on the server side. Maximum — 5000 records per call.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/doc-templates?limit=10&filter[active]=Y" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/doc-templates?limit=10&filter[active]=Y" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/doc-templates?limit=10&filter[active]=Y', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data, meta } = await res.json()
console.log(`Found ${meta.total} templates`)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/doc-templates?limit=10&filter[active]=Y', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data, meta } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Array of templates |
| `data[].id` | number | Template identifier |
| `data[].name` | string | Name |
| `data[].active` | string | Availability: `Y` / `N` |
| `data[].code` | string \| null | System code of the template |
| `data[].region` | string | Region |
| `data[].sort` | number | Order in the list |
| `data[].createTime` | string | Creation date (ISO 8601) |
| `data[].updateTime` | string | Update date (ISO 8601) |
| `data[].createdBy` | number | Identifier of the employee who created it |
| `data[].updatedBy` | number \| null | Identifier of the employee who changed it |
| `data[].moduleId` | string | Source module of the template |
| `data[].fileId` | number | Disk file identifier |
| `data[].bodyType` | string | Document body format |
| `data[].numeratorId` | number | Numerator identifier |
| `data[].withStamps` | string | Stamps and signatures: `Y` / `N` |
| `data[].productsTableVariant` | string | Products table variant in the document |
| `data[].isDeleted` | boolean | Whether the template is marked deleted |
| `data[].isDefault` | string | Default template: `Y` / `N` |
| `data[].users` | array | Identifiers of employees who have access to the template |
| `data[].download` | string | Document download URL |
| `data[].downloadMachine` | string | Download URL for programmatic access |
| `meta.total` | number | Total number of records matching the filter |
| `meta.hasMore` | boolean | Whether there are more records beyond `limit` |

Full template field schema — [Template fields](./fields.md).

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": 209,
      "active": "Y",
      "name": "Contract template",
      "code": null,
      "region": "us",
      "sort": 500,
      "createTime": "2026-05-12T09:03:38.000Z",
      "updateTime": "2026-05-12T09:03:38.000Z",
      "createdBy": 1,
      "updatedBy": null,
      "moduleId": "rest",
      "fileId": 9175,
      "bodyType": "Bitrix\\DocumentGenerator\\Body\\Docx",
      "numeratorId": 1,
      "withStamps": "N",
      "productsTableVariant": "",
      "isDeleted": false,
      "isDefault": "N",
      "users": ["U1"],
      "download": "/bitrix/services/main/ajax.php?action=documentgenerator.api.template.download&SITE_ID=s1&id=209",
      "downloadMachine": "https://<portal>/rest/1/<token>/documentgenerator.api.template.download/?token=<token>"
    },
    {
      "id": 211,
      "active": "Y",
      "name": "Invoice template",
      "code": null,
      "region": "us",
      "sort": 500,
      "createTime": "2026-05-12T09:04:38.000Z",
      "updateTime": "2026-05-12T09:04:38.000Z",
      "createdBy": 1,
      "updatedBy": null,
      "moduleId": "rest",
      "fileId": 5901,
      "bodyType": "Bitrix\\DocumentGenerator\\Body\\Docx",
      "numeratorId": 1,
      "withStamps": "N",
      "productsTableVariant": "",
      "isDeleted": false,
      "isDefault": "N",
      "users": ["U1"],
      "download": "/bitrix/services/main/ajax.php?action=documentgenerator.api.template.download&SITE_ID=s1&id=211",
      "downloadMachine": "https://<portal>/rest/1/<token>/documentgenerator.api.template.download/?token=<token>"
    }
  ],
  "meta": {
    "total": 2,
    "hasMore": false
  }
}
```

## Error response example

400 — filter by a nonexistent field. The message lists the fields available for filtering:

```json
{
  "success": false,
  "error": {
    "code": "UNKNOWN_FILTER_FIELD",
    "message": "Unknown filter field 'bogusField' for entity 'doc-templates'. Available: id, name, numeratorId, region, code, moduleId, active, bodyType, withStamps, sort, users, fileId, file, createdBy, updatedBy, isDeleted, createTime, updateTime, download, downloadMachine, providers, isDefault, productsTableVariant"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `UNKNOWN_FILTER_FIELD` | Filter by a nonexistent field; the message lists the available fields |
| 403 | `SCOPE_DENIED` | The key lacks the `documentgenerator` scope |
| 401 | `TOKEN_MISSING` | The key has no configured tokens |

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

## Known specifics

**Sorting and windowing happen on the Vibecode side.** `order`, `offset`, and `limit` are applied on the Vibecode side: the full set is fetched, sorted, and sliced to the requested window. `total` and `hasMore` are computed from the collected set.

**Sort by a nonexistent field.** An `order` parameter on a field that does not exist does not raise an error — the request succeeds with status `200`, and the unknown sort field is skipped.

**String sorting is byte-wise.** Sorting by string fields (`name`, `region`) compares strings byte by byte, with no locale or case awareness, so the order of mixed-case values may differ from a "human" collation. Numeric (`id`, `sort`) and datetime (`createTime`, `updateTime`) fields sort correctly. Empty values (`null` / empty string) always sort to the end.

## See also

- [Get template](/docs/entities/doc-templates/get)
- [Search templates](/docs/entities/doc-templates/search)
- [Template fields](/docs/entities/doc-templates/fields)
- [Filtering syntax](/docs/filtering)
