---
title: "Upload a Word file as a template"
method: POST
path: "/v1/doc-gen/templates"
tags: ["Document Generation"]
---

# Upload a Word file as a template

`POST /v1/doc-gen/templates`

## Request

- Base URL: `https://api.talonic.com`
- URL: `https://api.talonic.com/v1/doc-gen/templates`
- Auth: HTTP bearer

The Word file travels as base64 in a JSON body, not as multipart. The request body limit is 5 MB, so the Word file can be about 3.7 MB at most. The file's content controls become the template's field sheet; every field starts unconfirmed with a suggested source. The kind is a letter unless `kind` or the file name says agreement. Requires a person at or above member behind the key.

## Request body

- DocGenUploadTemplateRequest
  - `filename` string, required
  - `content_base64` string, required: The .docx or .dotx bytes as base64; line breaks are allowed. Bounded by the 5 MB request body limit.
  - `name` string: Defaults to the file name without its extension.
  - `group` string
  - `kind` 'letter' | 'agreement'
  - `version` string: Defaults to a `(MM-YYYY)` date found in the file name.

## Response `201`

The created template with its field sheet.

- DocGenTemplate
  - `id` string, uuid
  - `index` integer: Position in creation order, starting at 1.
  - `name` string
  - `file` string: The uploaded file name.
  - `group` string: Empty when the template has no group.
  - `kind` 'letter' | 'agreement'
  - `pairId` string, uuid, nullable: The companion template generated with this one.
  - `version` string: Empty when the template has no version.
  - `fields` DocGenTemplateField[]
    - `key` string
    - `label` string
    - `kind` 'text' | 'choice' | 'date'
    - `options` string[]: The choices a dropdown control offers; empty for free text and dates.
    - `dateFormat` string, nullable: The Word date format of a date control, such as `dd.MM.yyyy`.
    - `where` string[]: Document parts the field sits in (body, header or footer).
    - `zone` 'header' | 'address' | 'reference' | 'body' | 'signature' | 'footer'
    - `group` string, nullable: The block of the text the field belongs to, such as an address.
    - `controls` string[]: The Word content controls (by id) this field fills.
    - `source` DocGenFieldSource: Where a field's value comes from. `type` selects the shape: `product` (`field`), `reference` (`column`), `extract` (`from`, `pattern`, optional `group` 0-9, optional `mode` `capture` or `remove`), `first` (`sources`, a list of product, reference, extract or party sources), `case` (`caseKey`, optional `when` condition), `user` (`profile`), `rule` (`rule`), `today`, `party` (`role`, `attribute`), `variant` (`by`, `map`, `fallback`), `condition` (`when`, optional `text`), `fixed` (`text`), and `lookup` (`from`, `cases`, `fallback`). A source is validated when stored; one of no known shape is refused.
      - `type` 'product' | 'reference' | 'extract' | 'first' | 'case' | 'user' | 'rule' | 'today' | 'party' | 'variant' | 'condition' | 'fixed' | 'lookup', required
    - `confirmed` boolean: True once a person confirmed the source; until then it is the platform's suggestion.
    - `reason` string, nullable: Why the platform suggested this source.
    - `spot` object, nullable: For a red passage of the template, the words as the template prints them.
      - `original` string
  - `dataProductId` string, uuid, nullable: The data product the field sheet was last proposed for; null until a proposal ran.
  - `updatedAt` string, date-time
  - `uploadedBy` string
  - `generated` integer: How many batches used the template.
  - `lastUsedAt` string, date-time, nullable

## Other responses

- `400`: The request is invalid.
- `403`: The API key does not have the required scope.
- `413`: The uploaded file exceeds the size limit.
- `422`: The file is not a Word document (.docx or .dotx) or could not be read.
- `502`: The template file could not be stored.

## Changes

- **2026-10-28** `0a485a46163e`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/talonic/apis/talonic-api/changes/v1/doc-gen/templates/post.md)

---

[API](https://skmtc.dev/talonic/apis/talonic-api.md) - [All operations](https://skmtc.dev/talonic/apis/talonic-api/llms.txt) - [OpenAPI document](https://skmtc.dev/talonic/apis/talonic-api/revisions/9f6d53e2ab5e?raw)
