> For the complete documentation index, see [llms.txt](https://teamleader-sdk.mcore-services.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teamleader-sdk.mcore-services.dev/api-reference/general/document-templates.md).

# Document Templates

Manage document templates in Teamleader Focus.

```php
Teamleader::documentTemplates()
```

|                          |                                                                   |
| ------------------------ | ----------------------------------------------------------------- |
| Class                    | `McoreServices\TeamleaderSDK\Resources\General\DocumentTemplates` |
| Create / update / delete | — / — / —                                                         |
| Pagination               | No                                                                |

## Endpoints

* `documentTemplates.list`

## Filters

Passed as the first argument to `list()`. Any other key throws.

| Filter          | Description                                  |
| --------------- | -------------------------------------------- |
| `department_id` | Department UUID (required)                   |
| `document_type` | Type of document template (required)         |
| `status`        | Filter by template status (active, archived) |

## Accepted values

Public constants on the class. Body fields and enum values outside these lists throw before the request is sent.

| Constant         | Values                                                                                                     |
| ---------------- | ---------------------------------------------------------------------------------------------------------- |
| `DOCUMENT_TYPES` | `delivery_note`, `invoice`, `order`, `order_confirmation`, `quotation`, `timetracking_report`, `workorder` |
| `STATUSES`       | `active`, `archived`                                                                                       |

## Methods

### `activeForDepartment()`

```php
activeForDepartment(string $departmentId, string $documentType): array
```

Get active document templates for a specific department and type

* `$departmentId` — Department UUID
* `$documentType` — Document type

### `byType()`

```php
byType(string $departmentId, string $documentType, array $additionalFilters = []): array
```

Get document templates by document type for a specific department

* `$departmentId` — Department UUID
* `$documentType` — Document type
* `$additionalFilters` — Additional filters (like status)

### `list()`

```php
list(array $filters = [], array $options = []): array
```

List document templates with filtering

Note: Both department\_id and document\_type are REQUIRED parameters

* `$filters` — Filters to apply (department\_id and document\_type are required)
* `$options` — Additional options (not used for this endpoint)

**Throws** `InvalidArgumentException` When required parameters are missing

### `archivedForDepartment()`

```php
archivedForDepartment(string $departmentId, string $documentType): array
```

Get archived document templates for a specific department and type

* `$departmentId` — Department UUID
* `$documentType` — Document type

### `allForDepartment()`

```php
allForDepartment(string $departmentId, ?array $documentTypes = null): array
```

Get all document templates for a department (across all types) Note: This will make multiple API calls since document\_type is required

* `$departmentId` — Department UUID
* `$documentTypes` — Array of document types to fetch

### `getAvailableDocumentTypes()`

```php
getAvailableDocumentTypes(): array
```

Get available document types based on API documentation

### `getAvailableStatuses()`

```php
getAvailableStatuses(): array
```

Get available status values for filtering

### `getDocumentTypeDisplayNames()`

```php
getDocumentTypeDisplayNames(): array
```

Get document type display names for UI

### `info()`

```php
info($id, $includes = null)
```

Override info method since it's not supported for document templates

### `create()`

```php
create(array $data)
```

Override create method since it's not supported

### `update()`

```php
update($id, array $data)
```

Override update method since it's not supported

### `delete()`

```php
delete($id, ...$additionalParams): array
```

Override delete method since it's not supported

## Examples

Get document templates for a specific department and type:

```php
$templates = Teamleader::documentTemplates()->list([
                'department_id' => 'a344c251-2494-0013-b433-ccee8e8435e5',
                'document_type' => 'invoice'
            ]);
```

Get only active document templates:

```php
$templates = Teamleader::documentTemplates()->list([
                'department_id' => 'a344c251-2494-0013-b433-ccee8e8435e5',
                'document_type' => 'invoice',
                'status' => ['active']
            ]);
```

Get templates by document type for a department:

```php
$invoiceTemplates = Teamleader::documentTemplates()->byType('department-id', 'invoice');
```

Get active templates for a department:

```php
$activeTemplates = Teamleader::documentTemplates()->activeForDepartment('department-id', 'quotation');
```
