---
title: "Create Document from Template"
method: POST
path: "/document_generation/create-from-template"
tags: ["Document AI — DMS"]
---

# Create Document from Template

`POST /document_generation/create-from-template`

## Request

- Base URL: `https://api.paperoffice.ai/latest`
- URL: `https://api.paperoffice.ai/latest/document_generation/create-from-template`
- Auth: HTTP bearer

Create a new PDF document in a workspace from a document generation template and store it in the DMS.

## Request body

- object
  - `template_id` string, required: Template ID from po_templates_list (e.g. tpl_invoice_standard_1a2b3c4d).
  - `variables` object, required: Template placeholder values as a JSON object, not an array. Required. JSON [] returns HTTP 400 VARIABLES_INVALID. Empty object {} is allowed and then checked against variables_schema.required. Fields listed in the template variables_schema.required must be present and non-empty or the call returns HTTP 400 and creates no document. Extra keys are allowed. Arrays for {{#each}} blocks.
  - `output_format` 'pdf': Rendered output format. Only pdf is available.
  - `workspace_id` integer, required: Target workspace ID (required). Use po_workspaces_list to find valid workspace IDs. The caller needs upload rights in this workspace.
  - `title` string: Document title (overrides the template name). May contain {{variable}} placeholders.
  - `metadata` object: Additional metadata stored as document meta fields.
  - `auto_classify` boolean: When true, order AI-DMS processing for the generated document (billed separately).
  - `ai_dms_tier` 'basic' | 'premium' | 'ultra': AI-DMS tier used when auto_classify is true and the workspace does not order AI-DMS automatically.
  - `processing_lane` 'no_sla' | 'sla_24h' | 'sla_12h' | 'sla_6h' | 'sla_1h' | 'instant': Start-SLA lane (wait-to-start guarantee, not completion). Values: no_sla (fair use ×1), sla_24h (×1.5), sla_12h (×2), sla_6h (×3), sla_1h (×4), instant (×5 interactive start). Prefer this over legacy numeric priority. If omitted: workspace default_processing_lane, else no_sla.
  - `template_version` integer: Corporate plan and above: Pin a template version (default: current). List versions with po_templates_versions_list.
  - `locale` string: Corporate plan and above: Locale for numbers, dates and currency (e.g. de_DE, en_GB). Default: template locale, then workspace locale.
  - `idempotency_key` string: Corporate plan and above: Retry-safe key: the same key with the same request returns the first document (HTTP 200, no second charge); with a different request HTTP 409.

## Response `200`

Success

- SuccessEnvelope: Success envelope. Payload fields are endpoint-specific (top-level fields, `result`/`job_result` for jobs, `data` on some account endpoints).
  - `status` 'success', required
  - `processing_time` union
    - string
    - number
  - `_billing` object

## Other responses

- `201`: Created
- `4XX`: Error
- `5XX`: Error

---

[API](https://skmtc.dev/paperoffice/apis/paperoffice-ai-api.md) · [All operations](https://skmtc.dev/paperoffice/apis/paperoffice-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/paperoffice/apis/paperoffice-ai-api/revisions/c6a6228a4509?raw)
