REST APIv1

API documentation

Generate PDFs from your HTML templates with one POST request. Pass Handlebars context as JSON and get back a URL to the file.

Overview

How rendering works

You create a template in Templar (HTML with Handlebars). The render API loads that template for your account, merges your data object, produces a PDF, and responds with JSON that includes a full absolute url to the file use that value directly; you do not need to combine it with a separate base. Each successful render consumes one credit.

Authentication

API keys

Every request must include a valid key in the Authorization header using the Bearer scheme (same as the in-app playground).

Header
Send exactly one non-revoked key per request.
Authorization: Bearer <YOUR_API_KEY>

Endpoint

Render PDF

POST/api/pdf/render

Request body must be JSON. The playground builds this payload for you and shows the raw response (status + JSON body), including a url field on success.

Examples
const res = await fetch(`https://templar.odysii.in/api/pdf/render`, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer YOUR_API_KEY`,
  },
  body: JSON.stringify({
  "templateName": "my-invoice",
  "data": {
    "invoice_no": "INV-001",
    "client_name": "Acme Corp",
    "total": 4200
  },
  "pageSize": "letter"
}),
});

const json = await res.json();
console.log(json);

Request body

Parameters

templateName
Required · string · must match a template name on your account (not deleted).
data
Required · JSON object or array · passed to Handlebars as the template context (same shape as mock data in the playground).
pageSize
Optional · string · defaults to a4. Use lowercase keys below.
ValuePaper
a4A4 (210mm 297mm)
letterLetter (8.5in 11in)
legalLegal (8.5in 14in)
a3A3 (297mm 420mm)
a5A5 (148mm 210mm)

Success

Responses

On 200, the body matches what the playground shows in the response panel: a JSON object with a downloadable PDF location and a short message.

{
  "url": "https://your-origin/outputs/pdf-… .pdf",
  "message": "PDF generated Successfully"
}

The client parses JSON from the response text; if parsing fails, the playground falls back to a raw text wrapper, your integration should prefer checking res.ok and reading json.error on failures.

Errors

HTTP status reference

Error bodies use { "error": "…" } with the messages below (same strings returned by the API).

StatusMeaning
401Missing or invalid API key (Unauthorized)
402No credits remaining.
400Invalid JSON, missing templateName, invalid data, or bad pageSize
404Template not Found.

Next steps

Try the interactive playground with your real templates, or copy generated snippets for Node.js, cURL, Python, Go, Ruby, and Java.