Tailprint
Templates & Automation 7 min read • Published: 2026-11-13

Hosted & Custom PDF Templates: Data-Driven Mustache + Tailwind CSS Document Automation

Decouple document design from backend deployment. Learn how to render built-in and custom Mustache + Tailwind CSS templates with strict required_fields validation via POST /v1/templates.

Hardcoding giant HTML strings inside your backend microservices makes template updates painful: every time finance wants to tweak an invoice column or legal updates a contract clause, an engineer has to edit code, run CI/CD, and redeploy.

✨ Built-In + Custom Hosted Templates

Tailprint includes 4 server-calculated built-in templates (invoice-modern, receipt-minimal, certificate-classic, report-executive) and lets Starter+ accounts register unlimited Custom Mustache + Tailwind CSS Templates via POST /v1/templates with required field validation, default values, and automatic Dual-Brain JSON embedding.

1. Creating a Custom Hosted Template (POST /v1/templates)

Register your reusable HTML template once using standard Mustache syntax ({{variable}} for auto-escaped values, {{{raw_html}}} for unescaped markup, and {{#items}}...{{/items}} for repeating arrays):

curl -X POST https://tailprint.com/v1/templates \
  -H "Authorization: Bearer sec_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "acme-saas-quote",
    "title": "Acme Enterprise SaaS Quote",
    "category": "Sales",
    "format": "A4",
    "required_fields": ["quote_number", "customer.name", "items"],
    "default_data": {
      "currency": "EUR",
      "payment_terms": "Net 30 Days"
    },
    "html": "<div class=\"p-12 font-sans\"><h1 class=\"text-3xl font-black text-indigo-600\">Quote #{{quote_number}}</h1><p class=\"mt-2 text-slate-600\">Prepared for {{customer.name}} ({{payment_terms}})</p><table class=\"w-full mt-8 text-sm\"><thead><tr class=\"border-b\"><th class=\"text-left py-2\">Item</th><th class=\"text-right py-2\">Price</th></tr></thead><tbody>{{#items}}<tr class=\"border-b border-slate-100\"><td class=\"py-2\">{{name}}</td><td class=\"py-2 text-right font-bold\">{{price}} {{currency}}</td></tr>{{/items}}</tbody></table></div>"
  }'

2. Rendering Your Template with Pure JSON Data

Now your backend services can generate PDFs by sending only template_id and data to POST /v1/render/pdf (or POST /v1/render/batch). If any field listed in required_fields is missing, Tailprint returns a clean 400 Bad Request without deducting from your monthly render quota:

const pdf = await tp.renderPdf({
  template_id: 'acme-saas-quote',
  data: {
    quote_number: 'Q-2026-512',
    customer: { name: 'Nordic Logistics A/S' },
    items: [
      { name: 'Enterprise Platform License', price: '12,000' },
      { name: 'Dedicated Onboarding', price: '2,500' }
    ]
  },
  neural_implant: true,
  verify_seal: true
});

Ready to build with Tailprint?

Get 100 free vector PDF and image renders every month with zero credit card required.