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_KEY

Making 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 string
  • Accept: 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 PDF
  • Accept: 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:

Email Provider:
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

FieldTypeRequiredDescription
contactstringOptional-
emailstringOptionalEmail address
locationstringOptional-
namestringOptional-
phonestringOptionalPhone number
socialLinksarrayOptionalArray of social media links
titlestringOptional-

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

FieldTypeRequiredDescription
contentstringOptionalRich text content (HTML supported)

Field Structure:

{
  "content": "string"
}

Work Experience

Section ID: resume-experience

FieldTypeRequiredDescription
entriesarrayOptionalArray of work experience entries

Field Structure:

{
  "entries": [
    {
      "company": "string",
      "position": "string",
      "startDate": "string",
      "endDate": "string",
      "description": "string (HTML supported)"
    }
  ]
}

Education

Section ID: resume-education

FieldTypeRequiredDescription
entriesarrayOptionalArray of education entries

Field Structure:

{
  "entries": [
    {
      "institution": "string",
      "degree": "string",
      "year": "string"
    }
  ]
}

Skills

Section ID: resume-skills

FieldTypeRequiredDescription
categorystringOptional-
itemsarrayOptionalArray of entries

Field Structure:

{
  "category": "string",
  "items": []
}

Projects

Section ID: resume-projects

FieldTypeRequiredDescription
entriesarrayOptionalArray 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

FieldTypeRequiredDescription
entriesarrayOptionalArray of certification entries

Field Structure:

{
  "entries": [
    {
      "name": "string",
      "issuer": "string",
      "date": "string",
      "link": "string (URL)"
    }
  ]
}

Languages

Section ID: resume-languages

FieldTypeRequiredDescription
entriesarrayOptionalArray 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

FieldTypeRequiredDescription
companyLogostringOptionalImage URL
companyNamestringOptional-
companyAddressstringOptional-
companyEmailstringOptional-
companyPhonestringOptional-
invoiceNumberstringOptional-
invoiceDatestringOptionalDate string (YYYY-MM-DD format)
dueDatestringOptionalDate string (YYYY-MM-DD format)
billToNamestringOptional-
billToAddressstringOptional-
shipToNamestringOptional-
shipToAddressstringOptional-

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

FieldTypeRequiredDescription
itemsarrayOptionalArray of item entries

Field Structure:

{
  "items": [
    {
      "description": "string",
      "quantity": "string",
      "unitPrice": "string",
      "total": "string"
    }
  ]
}

Invoice Footer

Section ID: invoice-footer

FieldTypeRequiredDescription
subtotalstringOptional-
taxModestringOptionalstring (percentage | fixed)
taxRatestringOptionalNumeric string (percentage or amount)
taxAmountstringOptional-
showTaxRatebooleanOptionalNumeric string (percentage or amount)
discountModestringOptionalstring (percentage | fixed)
discountRatestringOptionalNumeric string (percentage or amount)
discountstringOptional-
showDiscountRatebooleanOptionalNumeric string (percentage or amount)
totalstringOptional-
paymentTermsstringOptional-
notesstringOptional-

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

FieldTypeRequiredDescription
storeLogostringOptionalImage URL
storeNamestringOptional-
storeAddressstringOptional-
storeEmailstringOptional-
storePhonestringOptional-
receiptNumberstringOptional-
receiptDatestringOptionalDate string (YYYY-MM-DD format)
transactionIdstringOptional-

Field Structure:

{
  "storeLogo": "string",
  "storeName": "string",
  "storeAddress": "string",
  "storeEmail": "string",
  "storePhone": "string",
  "receiptNumber": "string",
  "receiptDate": "string",
  "transactionId": "string"
}

Receipt Items

Section ID: receipt-items

FieldTypeRequiredDescription
itemsarrayOptionalArray of item entries

Field Structure:

{
  "items": [
    {
      "description": "string",
      "quantity": "string",
      "unitPrice": "string",
      "total": "string"
    }
  ]
}

Receipt Footer

Section ID: receipt-footer

FieldTypeRequiredDescription
subtotalstringOptional-
taxModestringOptionalstring (percentage | fixed)
taxRatestringOptionalNumeric string (percentage or amount)
taxAmountstringOptional-
showTaxRatebooleanOptionalNumeric string (percentage or amount)
discountModestringOptionalstring (percentage | fixed)
discountRatestringOptionalNumeric string (percentage or amount)
discountstringOptional-
showDiscountRatebooleanOptionalNumeric string (percentage or amount)
totalstringOptional-
paymentMethodstringOptional-
transactionIdstringOptional-
thankYouMessagestringOptional-

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"
}