Render a template
Send data to a template and get the finished document back.
POST /Send the template ID and the data as JSON. OpenTemplates fills the template, puts it into the layout of its profile and answers with the result.
Request
| Field | Type | What it does |
|---|---|---|
id | string | Required. The template ID: the profile identifier and the template identifier, for example demo/invoice. |
data | object | The data of the document, available as value in the template. It can also be a JSON string. Without it the template gets an empty object. |
output | string | html (the default). pdf, jpg and docx need a Total.js API token. |
Send the token as described in the REST API overview.
Example
curl -H "x-token: YOUR_TOKEN" -H "Content-Type: application/json" \
-d '{"id":"demo/invoice","data":{"number":"2026-002","customer":"Jane Doe","items":[{"name":"Consulting","price":300}],"total":300}}' \
https://templates.example.com/The answer is 200 with Content-Type: text/html:
<!DOCTYPE html>
<html>
<head>
<title>OpenTemplates</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style>
body, page { padding: 0; margin: 0; box-shadow: 0; background: #FFF; }
</style>
</head>
<body>
<page>
<div style="padding:40px">
<h1>Invoice 2026-002</h1>
<p>Customer: <b>Jane Doe</b></p>
<table style="width:100%;border-collapse:collapse">
<tr><td style="padding:5px 0">Consulting</td><td style="text-align:right">300.00 €</td></tr>
</table>
<p style="text-align:right">Total: <b>300.00 €</b></p>
</div>
</page>
</body>
</html>The sample model and the helper blocks of the template and the layout are not part of the output.
Send a form instead of JSON
The endpoint also accepts a URL-encoded form. Send data as a JSON string:
curl -H "x-token: YOUR_TOKEN" --data-urlencode "id=demo/welcome" --data-urlencode 'data={"name":"Jane"}' https://templates.example.com/Counters and logs
Every render adds one to the counters of the profile and the template and writes a log entry.
Errors
A missing id answers 400 with [{"error":"Invalid template ID"}], and an unknown template ID answers 400 with [{"error":"Template not found"}]. See Errors.