Fill a template from key-value pairs
Template
Type or paste a template here. Pasting from Word keeps headings, bold, bullets and tables. For the real Word document, upload the file below.
Word (.docx), Markdown or plain text, up to 4 MB. You get the filled file back.
Values
Paste values here as an AI model would send them. The API accepts common variations, reports each one it converts, and refuses what it would have to guess.
Result
A read-only preview, drawn in your browser. It may differ slightly from Word; the downloaded file is the exact result.
Find the placeholders, fill in the values, then Generate.
Syntax guide
Ordinary text in Word, Markdown or a text file. Markers still work if part of one changes font.
Values and formatting
{{Company_Name}} | A value. Names start with a letter: letters, digits, underscores. Capitals matter. |
[[{{Name}} /case(upper)]] | upper, lower or title. |
[[{{Fee}} /number("#,##0.00")]] | 0 required digit, # optional, comma for thousands; "0.##%" shows 0.6 as 60%. |
[[{{Date}} /date("D MMMM YYYY")]] | YYYY YY MMMM MMM MM M DD D. |
[[({{Price}} * {{Qty}}) /number("0.00")]] | + - * and parentheses. |
Lists
{{Names}} | Joins as "A, B, C". |
[[{{Names}} /list(separator=";"; last="and")]] | "A; B; and C". |
[[{{Names}} /list(layout=paragraph; separator="")]] | Only the item repeats, each as its own paragraph or bullet. Text before the marker stays with the first item, text after it with the last. |
[[{{Names}} /list(layout=row)]] | In a table cell: repeats the row (column repeats the column). |
Deleting text
[[DELIFNO({{Include}})@A]] … [[ENDDEL@A]] | Deletes the text between when the answer is No (DELIFYES: when Yes). Any other answer deletes nothing. May span paragraphs and tables. |
[[DELIFNO({{Include}}) /range(paragraph)]] | Deletes the paragraph it sits in; no ENDDEL. Also /range(line), row, column, table. |
{{Fee}} >= 1000000 AND NOT {{Waived}} | = != > < >= <=, AND, OR, NOT, CONTAINS, IS EMPTY. Text in quotes. |
Comments
<!-- note --> | Removed. A first comment starting TEMPLATE: may describe the fields in YAML. |
\{{Key}} | Shows the markup as written. |
When something is wrong
A document always comes back. A value not given shows [Key Name]; a calculation that cannot run shows [ValueERROR!]; a marker that cannot be read shows [SyntaxERROR!] and does nothing else. That includes row or column operations on merged cells, repeats inside repeats, and repeats in headers and footers.
Refused, with a message: review comments, tracked changes, hidden text, embedded objects; markup in footnotes, text boxes, content controls, hyperlinks or next to Word fields. The full rules are in the conversion guide.
API reference
Each call counts against your limit. Nothing is stored. API keys are not open yet. The exact description is in openapi.yaml; the full syntax is in the conversion guide.
| Call | Returns |
|---|---|
POST /v1/inspect | The template's keys to fill (with their kinds), a JSON Schema for the values, and any syntax errors with their locations. |
POST /v1/generate | The filled document. Problems show in it: [Key Name] for a value not given, [ValueERROR!] for a calculation that cannot run, [SyntaxERROR!] for a marker that cannot be read. A summary is in the X-Template-Report header (base64url JSON). |
Request
multipart/form-data: template (file), values (JSON object), optional format (docx, md, text) and strict. Markdown and text may be sent as JSON: {"format", "template", "values", "strict"}.
curl https://templates.applethub.ai/v1/generate \
-H "Authorization: Bearer $KEY" \
-F template=@letter.docx \
-F 'values={"Client_Name": "Acme Inc.", "Fee": 25000}' \
-o letter-filled.docx
Values
Text, numbers, true/false, null (not known), dates as YYYY-MM-DD, or lists of these. Without strict, a value is converted only when it has one possible reading, and every conversion is reported. A value that cannot be read is shown as given; a blank ("") is blank; null or a missing key shows [Key Name].
Limits
| This page, files | 5 calls a minute, 30 a day; up to 4 MB. |
| This page, typed templates | 30 calls a minute, 600 a day; up to 200 KB. |
| Everywhere | 1,000 items per list; 15 seconds per call. |