---
title: "Fill and generate a batch of documents"
method: POST
path: "/v1/doc-gen/jobs"
tags: ["Document Generation"]
---

# Fill and generate a batch of documents

`POST /v1/doc-gen/jobs`

## Request

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

Fills the documents as `POST /v1/doc-gen/drafts` does and generates a Word file and, where PDF conversion is available, a PDF for each. The batch is returned while it runs; poll `GET /v1/doc-gen/jobs/{id}`. The request is refused with 422 while documents leave fields empty, unless `allow_missing` is true (empty fields are then left out of the document). With `dry_run`, no batch is created and `job` is `null`. Unless `save_to_workspace` is false, the files are kept; otherwise they are deleted 24 hours after generation. Requires a person at or above member behind the key.

## Request body

- DocGenGenerateRequest: Name a template with `template_id` (and `with_pair`) or an explicit set with `template_ids`.
  - `template_id` string, uuid
  - `template_ids` string[]
  - `with_pair` boolean: Also generate the template's companion.
  - `data_product_id` string, uuid, required
  - `record_ids` string[], required: Row ids of the data product.
  - `values` object: Values for every document by field key. A field entered per document takes the value as entered, a passage decided per document takes yes or no, and any other field takes it as an edit over the fill.
  - `documents` DocGenDocumentValues[]: Values for single documents; they win over `values`.
    - `record_id` string, required
    - `template_id` string, uuid: Only this template's document; every template of the batch when omitted.
    - `values` object, required: Values by field key.
  - `profile` object: The writer's details for this batch only (name, kuerzel, titel, bereich, unterschrift); the saved profile is unchanged.
  - `save_to_workspace` boolean: When false, the files are deleted 24 hours after generation.
  - `allow_missing` boolean: Generate although some documents leave fields empty.
  - `dry_run` boolean

## Response `201`

The filled documents and the batch.

- DocGenGenerateResult
  - `dry_run` boolean
  - `documents` DocGenDraft[]
    - `template_id` string, uuid
    - `template_name` string
    - `record_id` string
    - `record_label` string
    - `filled` integer
    - `total` integer
    - `missing` object[]
      - `key` string
      - `label` string
      - `source` 'product' | 'reference' | 'extract' | 'first' | 'case' | 'user' | 'rule' | 'today' | 'party' | 'variant' | 'condition' | 'fixed' | 'lookup': The type of the field's source.
    - `values` object
  - `job` DocGenJob, nullable: The batch; `null` with `dry_run`.
    - `id` string, uuid
    - `templateIds` string[]
    - `templateNames` string[]
    - `createdAt` string, date-time
    - `by` string
    - `status` 'running' | 'completed' | 'failed'
    - `error` string, nullable
    - `savedToWorkspace` boolean
    - `pdfAvailable` boolean
    - `filesExpireAt` string, date-time, nullable: When the files of a batch not kept in the workspace are deleted.
    - `filesExpired` boolean: True once the files are gone; the values and history stay.
    - `documents` DocGenJobDocument[]
      - `id` string, uuid
      - `templateId` string, uuid
      - `templateName` string
      - `recordId` string
      - `recordLabel` string
      - `values` object
      - `events` DocGenAuditEvent[]
        - `id` string
        - `at` string, date-time
        - `by` string
        - `kind` 'filled' | 'entered' | 'edited' | 'reverted' | 'generated' | 'exported' | 'saved' | 'template_uploaded' | 'field_confirmed' | 'parties_chosen'
        - `field` string
        - `fieldLabel` string
        - `from` string, nullable
        - `to` string, nullable
        - `detail` string
        - `documentId` string
      - `status` 'pending' | 'ready' | 'failed'
      - `files` DocGenGeneratedFile[]: Empty once the batch's files have expired.
        - `kind` 'docx' | 'pdf'
        - `name` string
        - `size` integer: Bytes.
      - `error` string, nullable
      - `pdfError` string, nullable: Why the PDF is missing although the Word file was made.
    - `events` DocGenAuditEvent[]: Always empty; each document carries its own events.
      - `id` string
      - `at` string, date-time
      - `by` string
      - `kind` 'filled' | 'entered' | 'edited' | 'reverted' | 'generated' | 'exported' | 'saved' | 'template_uploaded' | 'field_confirmed' | 'parties_chosen'
      - `field` string
      - `fieldLabel` string
      - `from` string, nullable
      - `to` string, nullable
      - `detail` string
      - `documentId` string

## Other responses

- `400`: The request is invalid.
- `403`: The API key does not have the required scope.
- `404`: A template, or a row that is not in the data product or not readable by the key.
- `422`: Documents leave fields empty and `allow_missing` is not true, or the batch exceeds 500 documents.

## Changes

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

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