API reference
Upload a template once, then send JSON data to get a PDF back. Everything is plain HTTPS and JSON, so you can call Paperlane from any language or tool.
Overview
All endpoints live under /v1 on your Paperlane API URL. Early-access customers receive their API URL and key by email. The examples below use two shell variables:
export PAPERLANE_URL="https://your-paperlane-url"
export API_KEY="pl_..."Requests and responses are JSON, except template uploads for Word files (multipart form data) and rendered documents (the PDF or .docx file itself). Request bodies can be up to 10 MB.
Authentication
Send your API key as a bearer token on every request. Keys start with pl_ and are shown only once when they're created, so keep yours somewhere safe, such as a secrets manager. Never put it in browser or mobile app code.
Authorization: Bearer pl_...A missing or wrong key returns 401. Each key belongs to one account and can only see that account's templates.
Quick start
Render a PDF straight from inline HTML, with no saved template:
curl $PAPERLANE_URL/v1/render \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"html": "<h1>Hello {{name}}</h1>", "data": {"name": "Ada"}}' \
-o hello.pdfFor anything you'll make more than once, save it as a template and render it by its templateId.
const res = await fetch(`${process.env.PAPERLANE_URL}/v1/render`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ templateId, data: { customer: { name: 'Acme Corp' } } }),
});
if (!res.ok) throw new Error((await res.json()).error);
await fs.promises.writeFile('invoice.pdf', Buffer.from(await res.arrayBuffer()));Pythonimport os, requests
res = requests.post(
f"{os.environ['PAPERLANE_URL']}/v1/render",
headers={"Authorization": f"Bearer {os.environ['API_KEY']}"},
json={"templateId": template_id, "data": {"customer": {"name": "Acme Corp"}}},
)
res.raise_for_status()
open("invoice.pdf", "wb").write(res.content)HTML templates
HTML templates use Handlebars syntax with ordinary HTML and CSS. Use print CSS, such as page-break-before, to control page breaks.
| Syntax | What it does |
|---|---|
{{customer.name}} | Inserts a value, HTML-escaped |
{{#each items}}…{{/each}} | Repeats for each item in a list. Use ../field to reach outside the loop |
{{#if paid}}…{{else}}…{{/if}} | Shows a section only when a value is present |
{{currency total "USD"}} | Formats a number as money, such as $1,250.00 |
{{date issuedOn}} | Formats a date such as 2026-10-19 as October 19, 2026 |
{{multiply qty price}} | Multiplies two numbers, for line totals |
data: URIs rather than linking to them.Word templates
Type tags in single braces directly into a .docx file in Microsoft Word, Google Docs (downloaded as .docx) or LibreOffice. Formatting on the tag is kept in the output.
| Tag | What it does |
|---|---|
{customer.name} | Inserts a value. Missing values are left blank |
{#items}…{/items} | Repeats for each item in a list. Put it in a table row to repeat the row |
{#paid}…{/paid} | Shows a section when the value is true or present |
{^paid}…{/paid} | Shows a section when the value is false or missing |
Line breaks in your data become line breaks in the document. If a tag is broken, for example a missing closing brace, the upload is rejected with a message pointing to the tag.
Create a template
POST/v1/templates
HTML template
Send JSON with a name and the template content.
curl $PAPERLANE_URL/v1/templates \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Invoice", "content": "<h1>Invoice {{number}}</h1>"}'Word template
Send multipart form data with the .docx in a file field (up to 10 MB) and an optional name. Without a name, the file name is used.
curl $PAPERLANE_URL/v1/templates \
-H "Authorization: Bearer $API_KEY" \
-F "name=Welcome letter" \
-F "file=@letter.docx"Response 201
{ "id": "3f1c9a52-6a0e-4c4b-9d0e-2b7f3e8a1c44", "kind": "docx" }List templates
GET/v1/templates
Returns your templates, newest first.
[
{ "id": "3f1c9a52-…", "name": "Welcome letter", "kind": "docx", "created_at": "2026-10-19 18:02:11" }
]Delete a template
DELETE/v1/templates/{id}
Returns 204 with no body, or 404 if the template doesn't exist.
Render a document
POST/v1/render
Fills a template with your data and returns the file. Provide either templateId or inline html, not both.
| Field | Type | Description |
|---|---|---|
templateId | string | ID of a saved template |
html | string | Inline Handlebars HTML, for one-off documents |
data | object | Values for the template's fields. Optional |
output | "pdf" | "docx" | Defaults to pdf. docx returns the filled Word file and works only with Word templates |
options.format | "A4" | "Letter" | "Legal" | Page size for HTML templates. Defaults to A4 |
options.landscape | boolean | Landscape pages for HTML templates. Defaults to false |
options.margin | object | top, right, bottom, left as CSS lengths, such as "20mm". Each defaults to 15mm |
Word templates keep the page size and margins set in Word.
curl $PAPERLANE_URL/v1/render \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "3f1c9a52-6a0e-4c4b-9d0e-2b7f3e8a1c44",
"data": { "name": "Ada", "items": [{ "label": "Onboarding" }] },
"options": { "format": "Letter" }
}' \
-o letter.pdfResponse 200
The document itself, with Content-Type: application/pdf (or the Word type for docx) and a Content-Disposition file name based on the template name. Each successful render counts as one document toward your monthly limit.
Get usage
GET/v1/usage
Documents generated this calendar month (UTC) and your plan's limit.
{ "plan": "starter", "used": 132, "limit": 1000 }Errors
Errors return JSON with an error message, and sometimes a detail with more information.
{ "error": "Invalid DOCX template", "detail": ["The tag beginning with \"{name\" is unclosed"] }| Status | Meaning |
|---|---|
400 | The request is invalid, for example both or neither of templateId and html, an unsupported option value, or a broken Word template |
401 | The API key is missing or wrong |
402 | You've reached your plan's documents for this month |
404 | The template doesn't exist in your account |
422 | The template couldn't be filled with this data. detail explains why |
501 | PDF conversion for Word templates is temporarily unavailable. Request "output": "docx" or try again later |
Plans and limits
| Plan | Documents a month | Watermark |
|---|---|---|
| Free | 50 | Yes |
| Starter | 1,000 | No |
| Pro | 10,000 | No |
Limits reset on the first day of each month (UTC). Request bodies and template files can be up to 10 MB. See pricing, or email us with questions.