Generate Documents
Fill documents without storing them using POST /v1/doc-gen/drafts, or generate a batch of Word and PDF files with POST /v1/doc-gen/jobs, with origins per value.
Drafts and batches take the same request. It names the templates (template_id, with with_pair to add the template's companion, or an explicit template_ids list of 1 to 10), the data_product_id, and the record_ids of the rows (1 to 500). The platform fills each chosen template for each chosen row on the server, so a call produces templates times rows documents, and a batch holds at most 500 of them: a larger request is refused with 422.
POST /v1/doc-gen/drafts returns the filled documents and stores nothing. Each document lists its values with their origin, filled and total counts, and missing, the fields that would print empty, each with the type of its source. It needs only the read scope but, as a POST, a member or above behind the key. POST /v1/doc-gen/jobs does the same fill and then generates a Word file and, where PDF conversion is available, a PDF for each document. The batch is returned while it runs, and the files appear as the documents become ready.
Values can be set in the request. values applies to 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 sets values for single documents (a record_id, an optional template_id, and the values) and wins over values. profile replaces the writer details for this batch only. The request is refused with 422 while documents leave fields empty, unless allow_missing is true, in which case an empty field is left out of the document. A control that was a line of its own then takes its line with it.
/v1/doc-gen/draftsBody fields (drafts and jobs)
trueResponse fields (documents[])
cURL: Draft one document and inspect what is missing
curl -X POST "https://api.talonic.com/v1/doc-gen/drafts" \
-H "Authorization: Bearer $TALONIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template_id": "'$TEMPLATE_ID'",
"data_product_id": "'$PRODUCT_ID'",
"record_ids": ["'$RECORD_ID'"],
"values": { "closing_remark": "With kind regards" }
}'Response: 201 Draft with origins and a missing field
{
"templates": [{ "id": "3b1f6a52-8c0e-4f0a-9d5e-2a7c1e4b9d10", "name": "contract-letter" }],
"documents": [
{
"template_id": "3b1f6a52-8c0e-4f0a-9d5e-2a7c1e4b9d10",
"template_name": "contract-letter",
"record_id": "rec_0417",
"record_label": "C-2026-0417",
"filled": 11,
"total": 12,
"missing": [{ "key": "reference_line", "label": "Reference line", "source": "reference" }],
"values": {
"addressee": { "value": "Nordwind Energie GmbH", "origin": { "type": "product" } },
"closing_remark": { "value": "With kind regards", "origin": { "type": "edited" } }
}
}
]
}/v1/doc-gen/jobscURL: Generate despite one empty field
curl -X POST "https://api.talonic.com/v1/doc-gen/jobs" \
-H "Authorization: Bearer $TALONIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template_ids": ["'$TEMPLATE_ID'"],
"data_product_id": "'$PRODUCT_ID'",
"record_ids": ["'$RECORD_ID'"],
"allow_missing": true,
"save_to_workspace": true
}'running; poll GET /v1/doc-gen/jobs/{id} until its status is completed or failed. See Batches & Downloads for the batch shape and the file routes.