API Documentation
Complete guide to using our API for template preview and export functionality.
Introduction
Our API provides programmatic access to template preview and export functionality. You can generate HTML previews and PDF exports of your templates using simple HTTP requests.
Key features include: secure API key authentication, support for custom template data, multiple response formats (HTML/PDF or JSON), and comprehensive error handling.
Getting Started
Getting Your API Key
To use the API, you'll need an API key. Navigate to your organization settings, then go to the API Keys section. If you don't have a key yet, one will be automatically generated for you. Copy your API key and keep it secure - you'll use it to authenticate all API requests.
Authentication
All API requests must include your API key in the Authorization header using Bearer token authentication:
Authorization: Bearer YOUR_API_KEYMaking Your First API Call
Here's a simple example of how to preview a template using cURL:
curl -X POST "https://your-api-url.com/api/v1/templates/your-template-id/preview" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sections": {}}'API Documentation
Preview API
POST /api/v1/templates/:templateId/preview
Generate an HTML preview of a template. Returns the rendered HTML that can be displayed in a browser or embedded in your application.
Request Body
{
"sections": {
"resume-header": {
"name": "John Doe",
"title": "Software Engineer"
}
}
}Response
By default, returns HTML content. Include ?format=json or Accept: application/json header to get a JSON response:
// HTML format (default)
<html>...</html>
// JSON format (?format=json or Accept: application/json)
{
"html": "<html>...</html>"
}Query Parameters
format=json- Return JSON response with HTML stringAccept: application/json- Same as format=json
Export API
POST /api/v1/templates/:templateId/export
Generate a PDF export of a template. Returns a PDF file that can be downloaded, stored, or sent as an email attachment.
Request Body
{
"sections": {
"resume-header": {
"name": "John Doe",
"title": "Software Engineer"
}
}
}Response
By default, returns PDF binary content. Include ?format=json or Accept: application/json header to get a JSON response with base64-encoded PDF:
// PDF format (default)
Binary PDF content
// JSON format (?format=json or Accept: application/json)
{
"pdf": "base64-encoded-pdf-content"
}Query Parameters
format=json- Return JSON response with base64-encoded PDFAccept: application/json- Same as format=json
Use Cases: Sending PDFs via Email
Below are code examples for exporting a template as PDF and sending it as an email attachment using various email providers. Select your preferred email provider and programming language:
import "dotenv/config";
import nodemailer from "nodemailer";
const {
API_KEY,
API_BASE_URL,
TEMPLATE_ID,
EMAIL_PROVIDER = "mailgun",
EMAIL_TO,
EMAIL_FROM,
} = process.env;
async function exportDocument() {
const url = `${API_BASE_URL}/api/v1/templates/${TEMPLATE_ID}/export`;
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ sections: {} }),
});
if (!response.ok) {
throw new Error(`Export failed: ${response.status}`);
}
return Buffer.from(await response.arrayBuffer());
}
async function sendViaMailgun(pdfBuffer) {
const formData = new FormData();
formData.append("from", EMAIL_FROM);
formData.append("to", EMAIL_TO);
formData.append("subject", "Your Document Export");
formData.append("text", "Please find your document attached.");
formData.append("html", "<p>Please find your document attached.</p>");
const pdfBlob = new Blob([pdfBuffer], { type: "application/pdf" });
formData.append("attachment", pdfBlob, "document.pdf");
const auth = Buffer.from(`api:${process.env.MAILGUN_API_KEY}`).toString("base64");
const response = await fetch(
`https://api.mailgun.net/v3/${process.env.MAILGUN_DOMAIN}/messages`,
{
method: "POST",
headers: { Authorization: `Basic ${auth}` },
body: formData,
}
);
if (!response.ok) throw new Error("Mailgun API failed");
return await response.json();
}
async function main() {
const pdfBuffer = await exportDocument();
await sendViaMailgun(pdfBuffer);
}
main();Payload Schema Reference
Complete reference for all template types, sections, and fields. Each template type has specific sections with defined fields, data types, and requirements.
resume Template
Section ID format: resume-{sectionType}
Header
Section ID: resume-header
| Field | Type | Required | Description |
|---|---|---|---|
| contact | string | Optional | - |
string | Optional | Email address | |
| location | string | Optional | - |
| name | string | Optional | - |
| phone | string | Optional | Phone number |
| socialLinks | array | Optional | Array of social media links |
| title | string | Optional | - |
Field Structure:
{
"contact": "string",
"email": "string",
"location": "string",
"name": "string",
"phone": "string",
"socialLinks": [
{
"name": "string",
"link": "string (URL)"
}
],
"title": "string"
}Summary
Section ID: resume-summary
| Field | Type | Required | Description |
|---|---|---|---|
| content | string | Optional | Rich text content (HTML supported) |
Field Structure:
{
"content": "string"
}Work Experience
Section ID: resume-experience
| Field | Type | Required | Description |
|---|---|---|---|
| entries | array | Optional | Array of work experience entries |
Field Structure:
{
"entries": [
{
"company": "string",
"position": "string",
"startDate": "string",
"endDate": "string",
"description": "string (HTML supported)"
}
]
}Education
Section ID: resume-education
| Field | Type | Required | Description |
|---|---|---|---|
| entries | array | Optional | Array of education entries |
Field Structure:
{
"entries": [
{
"institution": "string",
"degree": "string",
"year": "string"
}
]
}Skills
Section ID: resume-skills
| Field | Type | Required | Description |
|---|---|---|---|
| category | string | Optional | - |
| items | array | Optional | Array of entries |
Field Structure:
{
"category": "string",
"items": []
}Projects
Section ID: resume-projects
| Field | Type | Required | Description |
|---|---|---|---|
| entries | array | Optional | Array of project entries |
Field Structure:
{
"entries": [
{
"name": "string",
"description": "string (HTML supported)",
"technologies": "array<string>",
"link": "string (URL)",
"date": "string"
}
]
}Certifications
Section ID: resume-certifications
| Field | Type | Required | Description |
|---|---|---|---|
| entries | array | Optional | Array of certification entries |
Field Structure:
{
"entries": [
{
"name": "string",
"issuer": "string",
"date": "string",
"link": "string (URL)"
}
]
}Languages
Section ID: resume-languages
| Field | Type | Required | Description |
|---|---|---|---|
| entries | array | Optional | Array of language entries |
Field Structure:
{
"entries": [
{
"language": "string",
"proficiency": "string (Beginner | Intermediate | Advanced | Fluent | Native)"
}
]
}invoice Template
Section ID format: invoice-{sectionType}
Invoice Header
Section ID: invoice-header
| Field | Type | Required | Description |
|---|---|---|---|
| companyLogo | string | Optional | Image URL |
| companyName | string | Optional | - |
| companyAddress | string | Optional | - |
| companyEmail | string | Optional | - |
| companyPhone | string | Optional | - |
| invoiceNumber | string | Optional | - |
| invoiceDate | string | Optional | Date string (YYYY-MM-DD format) |
| dueDate | string | Optional | Date string (YYYY-MM-DD format) |
| billToName | string | Optional | - |
| billToAddress | string | Optional | - |
| shipToName | string | Optional | - |
| shipToAddress | string | Optional | - |
Field Structure:
{
"companyLogo": "string",
"companyName": "string",
"companyAddress": "string",
"companyEmail": "string",
"companyPhone": "string",
"invoiceNumber": "string",
"invoiceDate": "string",
"dueDate": "string",
"billToName": "string",
"billToAddress": "string",
"shipToName": "string",
"shipToAddress": "string"
}Invoice Items
Section ID: invoice-items
| Field | Type | Required | Description |
|---|---|---|---|
| items | array | Optional | Array of item entries |
Field Structure:
{
"items": [
{
"description": "string",
"quantity": "string",
"unitPrice": "string",
"total": "string"
}
]
}Invoice Footer
Section ID: invoice-footer
| Field | Type | Required | Description |
|---|---|---|---|
| subtotal | string | Optional | - |
| taxMode | string | Optional | string (percentage | fixed) |
| taxRate | string | Optional | Numeric string (percentage or amount) |
| taxAmount | string | Optional | - |
| showTaxRate | boolean | Optional | Numeric string (percentage or amount) |
| discountMode | string | Optional | string (percentage | fixed) |
| discountRate | string | Optional | Numeric string (percentage or amount) |
| discount | string | Optional | - |
| showDiscountRate | boolean | Optional | Numeric string (percentage or amount) |
| total | string | Optional | - |
| paymentTerms | string | Optional | - |
| notes | string | Optional | - |
Field Structure:
{
"subtotal": "string",
"taxMode": "string",
"taxRate": "string",
"taxAmount": "string",
"showTaxRate": true,
"discountMode": "string",
"discountRate": "string",
"discount": "string",
"showDiscountRate": true,
"total": "string",
"paymentTerms": "string",
"notes": "string"
}receipt Template
Section ID format: receipt-{sectionType}
Receipt Header
Section ID: receipt-header
| Field | Type | Required | Description |
|---|---|---|---|
| storeLogo | string | Optional | Image URL |
| storeName | string | Optional | - |
| storeAddress | string | Optional | - |
| storeEmail | string | Optional | - |
| storePhone | string | Optional | - |
| receiptNumber | string | Optional | - |
| receiptDate | string | Optional | Date string (YYYY-MM-DD format) |
| transactionId | string | Optional | - |
Field Structure:
{
"storeLogo": "string",
"storeName": "string",
"storeAddress": "string",
"storeEmail": "string",
"storePhone": "string",
"receiptNumber": "string",
"receiptDate": "string",
"transactionId": "string"
}Receipt Items
Section ID: receipt-items
| Field | Type | Required | Description |
|---|---|---|---|
| items | array | Optional | Array of item entries |
Field Structure:
{
"items": [
{
"description": "string",
"quantity": "string",
"unitPrice": "string",
"total": "string"
}
]
}Receipt Footer
Section ID: receipt-footer
| Field | Type | Required | Description |
|---|---|---|---|
| subtotal | string | Optional | - |
| taxMode | string | Optional | string (percentage | fixed) |
| taxRate | string | Optional | Numeric string (percentage or amount) |
| taxAmount | string | Optional | - |
| showTaxRate | boolean | Optional | Numeric string (percentage or amount) |
| discountMode | string | Optional | string (percentage | fixed) |
| discountRate | string | Optional | Numeric string (percentage or amount) |
| discount | string | Optional | - |
| showDiscountRate | boolean | Optional | Numeric string (percentage or amount) |
| total | string | Optional | - |
| paymentMethod | string | Optional | - |
| transactionId | string | Optional | - |
| thankYouMessage | string | Optional | - |
Field Structure:
{
"subtotal": "string",
"taxMode": "string",
"taxRate": "string",
"taxAmount": "string",
"showTaxRate": true,
"discountMode": "string",
"discountRate": "string",
"discount": "string",
"showDiscountRate": true,
"total": "string",
"paymentMethod": "string",
"transactionId": "string",
"thankYouMessage": "string"
}