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.
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
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
template | body | string | yes | The template (or a text/plain body). | |
data | body | object | no | Data for one render (JSON object). | |
rows | body | array | no | Batch: render once per object (max 1,000), returns outputs. | |
engine | body | string | no | auto | mustache, liquid or auto. |
partials | body | object | no | Named templates for {{> name}} / {% render "name" %} (max 50). | |
output | body | string | no | text | text (no escaping) or html (values HTML-escaped). |
strict | body | boolean | no | false | Liquid: error on undefined variables. |
delimiters | body | string | no | Mustache: custom tags, e.g. <% %>. | |
action | body | string | no | variables: list the variables only. | |
format | body | string | no | json | json 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"}}}'const res = await fetch('https://apibox.io.vn/v1/template-render', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"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"
}
}
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/template-render",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"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"}}},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/template-render');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"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 = curl_exec($ch);
print_r(json_decode($response, true));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
Text Diff
Compare two texts by lines, words, characters, sentences or JSON and get the changes, a similarity score and a unified diff patch.
a-bSlugify
Turn titles into clean URL slugs: accents removed (Vietnamese đ included), custom separator, optional case keeping and maximum length.
123Text Statistics
Count words, characters, sentences, paragraphs and lines, estimate reading and speaking time, and list the most frequent words of a text.