---
title: "Change template metadata and fields by key"
method: PATCH
path: "/v1/doc-gen/templates/{id}"
tags: ["Document Generation"]
---

# Change template metadata and fields by key

`PATCH /v1/doc-gen/templates/{id}`

## Request

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

Metadata and field changes by key; fields not named stay as they are. A field may be renamed, given another source and confirmed, but a field cannot be added: the places a template fills come from the Word file. Unknown field keys, a source of no known shape, and conditions that read themselves are refused with 422. With `dry_run`, the response is the template as it would be and nothing is stored. Requires a person at or above member behind the key.

## Path parameters

- `id` string, uuid, required

## Request body

- DocGenUpdateTemplateRequest
  - `name` string
  - `group` string, nullable
  - `kind` 'letter' | 'agreement', nullable
  - `pair_template_id` string, uuid, nullable
  - `version` string, nullable
  - `fields` DocGenFieldChange[]
    - `key` string, required
    - `label` string
    - `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
    - `reason` string, nullable
  - `dry_run` boolean

## Response `200`

The template after the change, or as it would be with `dry_run`.

- DocGenUpdateTemplateResult
  - `dry_run` boolean
  - `template` 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.
- `404`: The requested resource was not found.
- `422`: An unknown field key, an unreadable source, or a condition that reads itself.

## Changes

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

[Operation history](https://skmtc.dev/talonic/apis/talonic-api/changes/v1/doc-gen/templates/:id/patch.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)
