Template renderer API

Render Mustache or Liquid templates with JSON data: loops, conditions, partials, Vietnamese filters (VND, amount in words, dd/mm/yyyy) and mail-merge rows.

POSThttps://apibox.io.vn/v1/template-render

Send a template and data and get the rendered text. Two engines run as interpreters (no code generation, safe on a serverless runtime): Mustache (logic-less, {{name}}, {{#items}}…{{/items}}, {{^empty}}, partials {{> header}}) and Liquid (LiquidJS: {% if %}, {% for %}, {% assign %}, {% render "part" %}, 40+ standard filters). engine=auto picks Liquid when the template uses {% %} tags or | filters.

Vietnamese filters work in both engines: vnd (1.500.000 đ), number_vi, vnd_words / so_thanh_chu (Một triệu năm trăm nghìn đồng), date_vn / ngay_vn (20/11/2026), date_vn_long / ngay_thang_nam (ngày 20 tháng 11 năm 2026), remove_accents / bo_dau, upcase_vi, slug_vi. In Liquid they are filters ({{ tong | vnd }}); in Mustache they are sections ({{#vnd}}{{tong}}{{/vnd}}).

output=html escapes values for HTML; the default text does not. rows renders the template once per object (up to 1,000, for SMS / Zalo / e-mail mail-merge). partials holds named templates for includes — no files or URLs are ever read. action=variables lists the variables a template uses. Limits: 200,000-character templates, 2 MB output, about 2 seconds of rendering; data is read through own properties only.

Markdown · OpenAPI · Postman · llms.txt

Parameters

NameInTypeRequiredDefault
templatebodystringyesThe template (or a text/plain body).
databodyobjectnoData for one render (JSON object).
rowsbodyarraynoBatch: render once per object (max 1,000), returns outputs.
enginebodystringnoautomustache, liquid or auto.
partialsbodyobjectnoNamed templates for {{> name}} / {% render "name" %} (max 50).
outputbodystringnotexttext (no escaping) or html (values HTML-escaped).
strictbodybooleannofalseLiquid: error on undefined variables.
delimitersbodystringnoMustache: custom tags, e.g. <% %>.
actionbodystringnovariables: list the variables only.
formatbodystringnojsonjson or raw (the text itself as text/plain or text/html).

Example

curl -X POST "https://apibox.io.vn/v1/template-render" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"engine":"liquid","template":"Kính gửi {{ khach.ten }},\nĐơn {{ don.ma }} gồm {% for sp in don.items %}{{ sp.ten }} x{{ sp.sl }}{% unless forloop.last %}, {% endunless %}{% endfor %}.\nTổng: {{ don.tong | vnd }} ({{ don.tong | so_thanh_chu }}), hạn thanh toán {{ don.han | ngay_vn }}.","data":{"khach":{"ten":"Anh Minh"},"don":{"ma":"DH-1024","items":[{"ten":"Áo thun","sl":2},{"ten":"Mũ","sl":1}],"tong":450000,"han":"2026-11-20"}}}'

Response

{
  "engine": "liquid",
  "output": "text",
  "result": "Kính gửi Anh Minh,\nĐơn DH-1024 gồm Áo thun x2, Mũ x1.\nTổng: 450.000 đ (Bốn trăm năm mươi nghìn đồng), hạn thanh toán 20/11/2026.",
  "length": 128,
  "variables": [
    {
      "name": "khach",
      "kind": "variable"
    },
    {
      "name": "don",
      "kind": "variable"
    }
  ]
}

Use cases

  • Compose dynamic e-mails, SMS or Zalo messages from Zapier, Make or n8n
  • Mail-merge plain-text notices for a list of customers
  • Render HTML snippets for invoices or receipts with VND amounts in words
  • Check which variables a template expects before wiring data

FAQ

Mustache or Liquid?

Mustache is simpler and logic-less; Liquid adds if / for / assign and filters. Use engine=auto to let the API choose from the syntax.

Is Handlebars supported?

Handlebars templates that only use Mustache syntax render with engine=mustache. Handlebars helpers are not supported because the Handlebars compiler generates code at run time.

What happens with an unknown variable?

It renders as empty. With engine=liquid and strict=true an undefined variable returns a missing_variable error instead.

Related APIs

Start with 1,000 free requests every month. Get free API key →