---
title: "Generate a document"
method: POST
path: "/v1/documents/generate"
tags: ["Documents"]
---

# Generate a document

`POST /v1/documents/generate`

Generate any document.
This API is designed to be used to generate GS1 labels,
invoices and any document that requires external data.

## Request body

- DocumentData
  - `template_id` string — The template name. **Required if template is not provided.**
  - `template` string — The template content. **Required if template_id is not provided.**
  - `doc_format` string — The format of the document
  - `doc_name` string — The file name
  - `data` object — The template data
  - `options` object — The template rendering options

## Response `201`

- GeneratedDocument
  - `template_id` string — The template name
  - `doc_format` string — The format of the document
  - `doc_name` string — The file name
  - `doc_file` string, required — A base64 file content

## Other responses

- `400`
- `404`
- `500`

---

[API](https://skmtc.dev/karrio/apis/karrio-api.md) · [All operations](https://skmtc.dev/karrio/apis/karrio-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/karrio/karrio-api/revisions/76ab3b7c3a61/schema)
