Templates API
List, retrieve, and manage templates via the REST API.
List Templates
Retrieve all templates in the current organization. Results are paginated.
GET /api/v1/templates
curl https://api.documentstack.dev/api/v1/templates \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"success": true,
"data": {
"templates": [
{
"id": "tmpl_abc123",
"name": "Invoice Template",
"projectId": "proj_xyz",
"version": 3,
"createdAt": "2025-06-01T08:00:00Z",
"updatedAt": "2025-07-10T14:22:00Z"
}
],
"pagination": {
"page": 1,
"pageSize": 20,
"total": 42,
"totalPages": 3
}
}
}Get a Template
Retrieve a single template by its ID, including the full element tree and page settings.
GET /api/v1/templates/:id
curl https://api.documentstack.dev/api/v1/templates/tmpl_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"success": true,
"data": {
"id": "tmpl_abc123",
"name": "Invoice Template",
"projectId": "proj_xyz",
"version": 3,
"pageSettings": {
"width": 595,
"height": 842,
"orientation": "portrait"
},
"elements": [ ... ],
"createdAt": "2025-06-01T08:00:00Z",
"updatedAt": "2025-07-10T14:22:00Z"
}
}Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | number | 1 | Page number |
pageSize | number | 20 | Items per page (max 100) |
projectId | string | — | Filter by project |
search | string | — | Search by template name |
Templates are always scoped to the organization associated with your API key. You cannot access templates from other organizations.
Template Object
| Field | Type | Description |
|---|---|---|
id | string | Unique template identifier |
name | string | Template display name |
projectId | string | Parent project ID |
version | number | Current version number |
pageSettings | object | Page dimensions, orientation, margins |
elements | array | Template elements (included only on single-template fetch) |
createdAt | string | ISO 8601 creation timestamp |
updatedAt | string | ISO 8601 last-modified timestamp |
Next Steps
- Projects API — Manage projects
- Generate API — Generate PDFs from templates
- Pagination — Navigate large result sets