Document Stack
Document Stack
Docs

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

ParameterTypeDefaultDescription
pagenumber1Page number
pageSizenumber20Items per page (max 100)
projectIdstringFilter by project
searchstringSearch by template name
Templates are always scoped to the organization associated with your API key. You cannot access templates from other organizations.

Template Object

FieldTypeDescription
idstringUnique template identifier
namestringTemplate display name
projectIdstringParent project ID
versionnumberCurrent version number
pageSettingsobjectPage dimensions, orientation, margins
elementsarrayTemplate elements (included only on single-template fetch)
createdAtstringISO 8601 creation timestamp
updatedAtstringISO 8601 last-modified timestamp

Next Steps