Render with a saved template
Use a saved template when the same document is generated again and again, such as invoices, quotes or reports. The layout lives in your account; each request carries only the data that changes.
1. Save the template
Section titled “1. Save the template”Create it in the portal, under Templates, with a live preview, or through the API:
curl -X POST https://api.example.com/v1/templates \ -H "Authorization: Bearer $RUSTEDF_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Invoice", "source": "<h1>Invoice {{ number }}</h1><p>{{ total | currency(code=\"USD\") }}</p>", "locale": "en-US", "sample_data": { "number": "2025-0042", "total": "2040.50" } }'The response includes the template id. See Templates for the syntax.
2. Render it
Section titled “2. Render it”Send the id and the data:
curl -X POST https://api.example.com/v1/render \ -H "Authorization: Bearer $RUSTEDF_KEY" \ -H "Content-Type: application/json" \ -d '{ "template_id": "0194f2c0-…", "data": { "number": "2025-0042", "total": "2040.50" } }' \ -o invoice.pdfThe locale of the template is used unless the request sends its own, so one template can
serve every market: send "locale": "de-DE" and the same invoice comes out formatted for
Germany.
Why use it
Section titled “Why use it”- The HTML does not travel with every request, so requests stay small.
- Designers and developers edit the template in the portal and test it with sample data, without a deploy on your side.
- Every change raises the template
version, and the next render uses the new one. - Templates are private to your account; another account’s id answers
404.
Your plan limits how many templates you can keep; see Plans and credits. For the full list of request fields and the response, see Rendering a PDF. If you would rather send the HTML yourself, see With inline HTML.