-
-
Notifications
You must be signed in to change notification settings - Fork 0
Document Templates
Read document template definitions in Teamleader Focus.
The Document Templates resource provides read-only access to the document templates configured in your Teamleader account. Templates are used when generating formatted documents such as invoices, quotations, and delivery notes.
Every call to list() requires both department_id and document_type β the API will not accept a request without them, and the SDK throws an InvalidArgumentException before the request is sent if either is missing.
info(), create(), update(), and delete() are not supported and throw a BadMethodCallException if called.
documentTemplates
| Capability | Supported |
|---|---|
| Pagination | β Not supported |
| Filtering | β
Required (department_id + document_type) |
| Sorting | β Not supported |
| Sideloading | β Not supported |
| Creation | β Not supported |
| Update | β Not supported |
| Deletion | β Not supported |
Returns document templates matching the given filters. Both department_id and document_type are required β an InvalidArgumentException is thrown if either is absent.
Required filters:
| Key | Type | Description |
|---|---|---|
department_id |
string | Department UUID |
document_type |
string | Document type β see Document Types |
Optional filters:
| Key | Type | Description |
|---|---|---|
status |
array |
['active'], ['archived'], or ['active', 'archived']
|
use McoreServices\TeamleaderSDK\Facades\Teamleader;
// Invoice templates for a department
$templates = Teamleader::documentTemplates()->list([
'department_id' => 'department-uuid',
'document_type' => 'invoice',
]);
// Active quotation templates only
$templates = Teamleader::documentTemplates()->list([
'department_id' => 'department-uuid',
'document_type' => 'quotation',
'status' => ['active'],
]);Convenience wrapper around list(). Accepts an optional array of additional filters (e.g. status).
// All templates of a type
$templates = Teamleader::documentTemplates()->byType(
'department-uuid',
'invoice'
);
// With status filter
$templates = Teamleader::documentTemplates()->byType(
'department-uuid',
'invoice',
['status' => ['active']]
);Shorthand for byType($departmentId, $documentType, ['status' => ['active']]).
$templates = Teamleader::documentTemplates()->activeForDepartment(
'department-uuid',
'quotation'
);Shorthand for byType($departmentId, $documentType, ['status' => ['archived']]).
$templates = Teamleader::documentTemplates()->archivedForDepartment(
'department-uuid',
'invoice'
);Fetches templates across all (or a specified subset of) document types for a department. Because document_type is required by the API, this method makes one API call per document type. If no $documentTypes array is provided, it iterates over all seven types returned by getAvailableDocumentTypes().
Failures on individual type calls are silently skipped; the remaining types are still fetched.
// All types β up to 7 API calls
$all = Teamleader::documentTemplates()->allForDepartment('department-uuid');
// Specific types only β 2 API calls
$selected = Teamleader::documentTemplates()->allForDepartment(
'department-uuid',
['invoice', 'quotation']
);Response structure differs from list():
[
'data' => [/* merged array of all template objects */],
'meta' => [
'department_id' => 'department-uuid',
'document_types_checked' => ['delivery_note', 'invoice', ...],
'total_templates' => 12,
],
]// All valid document type strings
$types = Teamleader::documentTemplates()->getAvailableDocumentTypes();
// Valid status values
$statuses = Teamleader::documentTemplates()->getAvailableStatuses();
// Display name map for building UI selects
$names = Teamleader::documentTemplates()->getDocumentTypeDisplayNames();
// ['delivery_note' => 'Delivery Note', 'invoice' => 'Invoice', ...]| Value | Display Name |
|---|---|
delivery_note |
Delivery Note |
invoice |
Invoice |
order |
Order |
order_confirmation |
Order Confirmation |
quotation |
Quotation |
timetracking_report |
Time Tracking Report |
workorder |
Work Order |
The UUID of the department whose templates you want.
$templates = Teamleader::documentTemplates()->list([
'department_id' => 'department-uuid',
'document_type' => 'invoice',
]);The document type string β must be one of the values in Document Types.
Must be passed as an array.
| Value | Description |
|---|---|
active |
Active templates |
archived |
Archived templates |
// Active only
$templates = Teamleader::documentTemplates()->list([
'department_id' => 'department-uuid',
'document_type' => 'invoice',
'status' => ['active'],
]);
// Both
$templates = Teamleader::documentTemplates()->list([
'department_id' => 'department-uuid',
'document_type' => 'invoice',
'status' => ['active', 'archived'],
]);[
'data' => [
[
'id' => 'template-uuid',
'name' => 'Standard Invoice',
],
],
]$templates = Teamleader::documentTemplates()->activeForDepartment(
config('teamleader.departments.sales'),
'invoice'
);
$defaultTemplate = $templates['data'][0] ?? null;$templates = Teamleader::documentTemplates()->activeForDepartment(
'department-uuid',
'quotation'
);
$options = array_column($templates['data'], 'name', 'id');
// ['uuid-1' => 'Standard Quotation', 'uuid-2' => 'Premium Quotation', ...]$cacheKey = 'tl_templates_' . $departmentId . '_' . $documentType;
$templates = Cache::remember($cacheKey, 3600, function () use ($departmentId, $documentType) {
return Teamleader::documentTemplates()->activeForDepartment($departmentId, $documentType);
});use BadMethodCallException;
use InvalidArgumentException;
use McoreServices\TeamleaderSDK\Exceptions\TeamleaderException;
// Missing required filter β thrown before the request is sent
try {
$templates = Teamleader::documentTemplates()->list([
'department_id' => 'department-uuid',
// document_type missing
]);
} catch (InvalidArgumentException $e) {
// 'document_type is required for document templates'
Log::error($e->getMessage());
}
// Unsupported methods all throw BadMethodCallException
try {
Teamleader::documentTemplates()->info('template-uuid');
} catch (BadMethodCallException $e) {
// Use list() with filters instead
}
// API-level errors
try {
$templates = Teamleader::documentTemplates()->byType('department-uuid', 'invoice');
} catch (TeamleaderException $e) {
Log::error('Teamleader error', ['message' => $e->getMessage()]);
}-
Departments β
department_idrequired for every request - Invoices β Templates are applied when generating invoices
- Quotations β Templates are applied when generating quotations
- Filtering β Filter reference
Last Updated: August 2026 β’ SDK Version: 2.2.2 β’ Made with β€οΈ by MCore Services
- Departments
- Users
- Teams
- Custom Fields
- Work Types
- Document Templates
- Currencies
- Notes
- Email Tracking
- Closing Days
- Day Off Types
- Days Off
- User Schedules
- Invoices
- Credit Notes
- Subscriptions
- Payment Methods
- Payment Terms
- Tax Rates
- Withholding Tax Rates
- Commercial Discounts
Next Gen Projects
Legacy Projects