logoKeepMot API
DocsAPI ReferenceTemplate API

Templates · Render

Template API

Render business data through a saved template and receive a production-ready PDF without sending page coordinates or element trees.

Use this endpoint when your team has agreed on a template ID and a stable set of business fields. The saved template controls layout, typography, tables, headers, and pagination.

Every object in data is rendered independently with the same template. Multiple objects are concatenated in order into a single multi-page PDF.

Endpoint

POST/pdf/template

Content-Type

application/json

Success

200 · application/pdf

Cache

no-store

Request body

JSON
template_id
stringrequired

The stable ID of a template saved in KeepMot. The template must exist before rendering starts.

data
object[]required

One or more business records. Values replace variable fields; omitted fields use their configured fallback values.

output
object

Optional output controls including delivery mode and the suggested PDF file name.

output.mode
binary | file

binary returns inline PDF bytes. file returns the same bytes with attachment-oriented content disposition.

output.file_name
string

Suggested output name. Use a .pdf suffix for clarity.

Request example

Send the JSON body below with a POST request. A successful response contains the generated PDF bytes.

JSON example
{
  "template_id": "fniuq7",
  "data": [
    {
      "invoice_items": [
        {
          "description": "Elite Quantum Cloud Compute",
          "qty": "1",
          "unit_price": "$1800"
        },
        {
          "description": "Dedicated RAG ",
          "qty": "2",
          "unit_price": "$2100"
        },
        {
          "description": "Ultra-low Latency",
          "qty": "3",
          "unit_price": "$510"
        }
      ]
    }
  ],
  "output": {
    "mode": "binary",
    "file_name": "table.pdf"
  }
}

Batch rendering

Add multiple objects to data to render the same template repeatedly. Their pages are merged in the same order as the array.

Fallback values

When a variable is not present in a data item, the template field fallback remains available to the PDF renderer.

Responses

StatusMessageDescription
200PDF generatedThe response body contains application/pdf bytes.
400Invalid template requesttemplate_id is missing, data is empty, or a data item is not an object.
401Authorization requiredThe Bearer API key is missing, invalid, expired, disabled, or its user is inactive.
402Insufficient Token balanceThe authenticated account does not have enough Tokens for the generated PDF pages.
404Template not foundNo non-deleted template exists for template_id.
415Unsupported mediaThe request Content-Type is not application/json.
422PDF render failedThe stored template is not a PDF document, or rendering/merging failed.
500PDF Worker errorAn unexpected Worker error occurred, including an unavailable PDF merge runtime.