Templates are the foundation of Fileloom. They combine HTML structure, CSS styling, and Handlebars placeholders to create dynamic, reusable PDF documents.
What is a Template?
A template is a saved document design that you can use repeatedly with different data. Instead of sending raw HTML with every API request, you:
Create a template once in the dashboard
Reference it by ID in API requests
Pass only the dynamic data
{
"templateId" : "tpl_invoice_v2" ,
"templateData" : {
"invoiceNumber" : "INV-2024-001" ,
"customerName" : "Acme Corp" ,
"total" : 1250.00
}
}
Template Components
Every template consists of:
Component Description HTML Document structure with Handlebars placeholders CSS Styling (colors, fonts, layout) Settings Paper size, margins, orientation Test Data Sample JSON for previewing
Template vs Raw HTML
Approach Best For Templates Repeated documents (invoices, reports), team collaboration, version control Raw HTML One-off documents, dynamic layouts, programmatic generation
Use templates for any document you’ll generate more than once. They’re faster (no HTML transfer), easier to maintain, and support versioning.
Creating Your First Template
Open Template Editor
Go to Templates → Create Template in the dashboard.
Write HTML
Create your document structure with Handlebars placeholders: < div class = "invoice" >
< h1 > Invoice #{{invoiceNumber}} </ h1 >
< p > Customer: {{customer.name}} </ p >
< p > Total: {{currency total "USD"}} </ p >
</ div >
Add CSS
Style your document in the CSS tab: .invoice {
font-family : 'Inter' , sans-serif ;
padding : 40 px ;
}
h1 { color : #333 ; }
Test with Data
Enter sample JSON in the Test Data tab: {
"invoiceNumber" : "INV-001" ,
"customer" : { "name" : "Acme Corp" },
"total" : 1250.00
}
Preview and Publish
Check the live preview, then click Publish to make it available via API.
Handlebars Basics
Fileloom uses Handlebars for dynamic content:
{{! Output a variable }}
{{ variableName }}
{{! Access nested properties }}
{{ customer.address.city }}
{{! Use helpers for formatting }}
{{ currency amount "USD" }}
{{ formatDate date "MMMM D, YYYY" }}
{{! Conditionals }}
{{ #if isPaid }} Paid {{ else }} Unpaid {{ /if }}
{{! Loops }}
{{ #each items }}
< li > {{ this.name }} : {{ currency this.price "USD" }} </ li >
{{ /each }}
See Handlebars Basics for complete syntax guide.
Built-in Helpers
Fileloom includes 70+ helpers for common operations:
Text & String uppercase, lowercase, truncate, replace
Numbers & Currency currency, formatNumber, percentage
Dates & Time formatDate, formatTime, addDays, now
Math & Logic add, multiply, round, gt, lt, and, or
Using Templates via API
Reference your template by ID:
curl -X POST https://api.fileloom.io/v1/pdf/generate \
-H "X-API-Key: fl_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"templateId": "tpl_abc123xyz",
"templateData": {
"invoiceNumber": "INV-2024-001",
"items": [
{"name": "Widget", "price": 29.99}
]
}
}'
Find template IDs in the dashboard templates list or template editor.
Next Steps