## Get a CRM document template

`GET /v1/crm-document-templates/:id`

Returns a single CRM document template by ID, together with the record types it is linked to and the employee access codes.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `id` (path) | number | yes | Template ID, a positive integer. List: [`GET /v1/crm-document-templates`](/docs/entities/crm-document-templates/list) |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/crm-document-templates/87" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/crm-document-templates/87" \
  -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/crm-document-templates/87', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log('Template:', data.name, 'linked to:', data.entityTypeId)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/crm-document-templates/87', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | The template |
| `data.id` | string | Template ID |
| `data.name` | string | Name |
| `data.region` | string | Template region, for example `uk` |
| `data.code` | string \| null | Symbolic code of the template |
| `data.active` | string | Availability: `Y` / `N` |
| `data.moduleId` | string | Owner module, always `crm` in this section |
| `data.numeratorId` | string | ID of the numerator that assigns numbers to documents |
| `data.withStamps` | string | Stamps and signatures: `Y` / `N` |
| `data.users` | object | Access codes of the employees who can see the template. The key and the value are identical and equal to the access code, for example `{"UA": "UA"}` means all employees |
| `data.isDeleted` | string | Whether the template is marked as deleted: `Y` / `N` |
| `data.sort` | string | Sort order in the list |
| `data.createTime` | string | Creation date in ISO 8601 |
| `data.updateTime` | string | Modification date in ISO 8601 |
| `data.entityTypeId` | array | CRM record types the template is linked to, as strings: `1` — lead, `3` — contact, `4` — company. Deals are broken down by funnel — `2_category_0`, `2_category_1` and so on, see [CRM document templates](/docs/entities/crm-document-templates) for details. A smart process with funnels is returned as `174_3`: the smart process type and the ID of its funnel. Smart process types: [`GET /v1/smart-processes`](/docs/entities/smart-processes) |
| `data.download` | string | Download URL of the template file in the Bitrix24 web interface. To download through the API, use `downloadMachine` |
| `data.downloadMachine` | string | Link for downloading the template file through the Vibecode API — [`GET /v1/crm-document-templates/:id/download`](/docs/entities/crm-document-templates/download) |

## Response example

```json
{
  "success": true,
  "data": {
    "id": "87",
    "name": "Addresses",
    "region": "uk",
    "code": null,
    "download": "https://example.bitrix24.com/bitrix/services/main/ajax.php?action=crm.documentgenerator.template.download&SITE_ID=s1&id=87",
    "active": "Y",
    "moduleId": "crm",
    "numeratorId": "1",
    "withStamps": "Y",
    "users": {
      "UA": "UA"
    },
    "isDeleted": "N",
    "sort": "366",
    "createTime": "2022-11-23T14:42:12+00:00",
    "updateTime": "2023-01-17T11:36:04+00:00",
    "entityTypeId": [
      "4",
      "3",
      "2_category_0",
      "2_category_1",
      "2_category_3",
      "174_3",
      "177_7",
      "177_9",
      "185_11",
      "1",
      "31_5"
    ],
    "downloadMachine": "https://vibecode.bitrix24.com/v1/crm-document-templates/87/download"
  }
}
```

## Error response example

404 — template not found:

```json
{
  "success": false,
  "error": {
    "code": "ENTITY_NOT_FOUND",
    "message": "CRM template not found."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 404 | `ENTITY_NOT_FOUND` | There is no template with this `id` on the portal |
| 404 | `ENTITY_NOT_FOUND` | A template with this `id` exists, but its `moduleId` is not `crm`, for example an application template. To read application templates, use [`GET /v1/doc-templates/:id`](/docs/entities/doc-templates/get) |
| 400 | `INVALID_PARAMS` | `id` is not a positive integer |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request to read the template. The reason is in `error.message` |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | The key has no tokens configured |
| 429 | `RATE_LIMITED` | Bitrix24 rate-limited requests to the portal. Retry after the delay in the `Retry-After` header |

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

## See also

- [List CRM document templates](/docs/entities/crm-document-templates/list)
- [Get templates for a CRM record](/docs/entities/crm-document-templates/available)
- [Update a template](/docs/entities/crm-document-templates/update)
- [Download a template](/docs/entities/crm-document-templates/download)
- [CRM document templates](/docs/entities/crm-document-templates)
