---
title: "Update Document Template"
method: POST
path: "/document_generation/template-update"
tags: ["Document AI — DMS"]
---

# Update Document Template

`POST /document_generation/template-update`

## Request

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

Update an existing document generation template: HTML content, header/footer, page layout, metadata, variables_schema or is_active.

## Request body

- object
  - `template_id` string, required: Template ID to update (required).
  - `name` string: Updated template display name.
  - `html_content` string: Updated HTML body with {{variable}} merge placeholders (max 5 MB).
  - `description` string: Updated template description.
  - `category` string: Template category (e.g. invoices, contracts, reports).
  - `variables_schema` object: Schema describing expected merge-field variables; its required list is enforced when generating.
  - `page_format` string: Page size (A4, A3, A5, Letter, Legal).
  - `page_orientation` 'portrait' | 'landscape': Page orientation: portrait or landscape.
  - `margin_top` integer: Top page margin in millimeters.
  - `margin_right` integer: Right page margin in millimeters.
  - `margin_bottom` integer: Bottom page margin in millimeters.
  - `margin_left` integer: Left page margin in millimeters.
  - `header_html` string: HTML snippet rendered at the top of each page (max 512 KB).
  - `footer_html` string: HTML snippet rendered at the bottom of each page (max 512 KB).
  - `is_active` 0 | 1: 1 = active template, 0 = deactivated (hidden from lists and generation).
  - `engine` 'hbs_v2' | 'po_regex_v1': Corporate plan and above: Template engine.
  - `custom_css` string: Corporate plan and above: CSS for the document.
  - `sample_data` object: Corporate plan and above: Sample variables for preview and validation.
  - `locale_default` string: Corporate plan and above: Default locale (e.g. de_DE).
  - `title_pattern` string: Corporate plan and above: Default document title with placeholders.
  - `image_data` string: Corporate plan and above: Template image for the app: https URL or PNG/JPEG/WebP/SVG data URI (max 2 MB); empty string removes it.
  - `change_note` string: Corporate plan and above: Note stored with the new version.
  - `expected_version` integer: Corporate plan and above: Optimistic lock: fail with HTTP 409 if the current version differs.
  - `restore_version` integer: Corporate plan and above: Create a new version with the content of this older version.

## 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

- `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)
