DocUnum

Render documents from templates

DocUnum is a document merge service. Feed it a template and a JSON payload, get back a finished document — no runtime dependencies, no magic.

DOCX XLSX ODT ODS HTML Markdown TXT

What it does

🔀

Field substitution

Replace [* field.path *] tags with values from a JSON payload, including nested objects and array indexing.

🧮

Expressions

Evaluate inline arithmetic and logic with [= qty * price =]. Built-in helpers: sum, avg, min, max, and more. Reference →

🔁

Loops & conditionals

Repeat blocks with for, branch with if / else, and scope with with — all inside any supported format.

📋

Template inspection

Use /peek to list every tag in a template before merging, and /validate to check data completeness.

🔍

Schema inference

Automatically derive a JSON Schema from any template so callers know exactly what data shape is expected.

🔄

Delimiter conversion

Migrate templates between delimiter schemes — e.g. [* *] to {{ }} — in a single API call.

API endpoints

POST /v1/merge Render a template with data. Returns the finished document as base64.
POST /v1/peek Inspect a template — returns tag inventory and control structure without merging.
POST /v1/validate Check template syntax and verify that all required fields are present in the data.
POST /v1/schema/infer Derive a draft-07 JSON Schema describing the expected data shape for a template.
POST /v1/convert Rewrite a template from one delimiter scheme to another.
GET /v1/templates List past template submissions (requires database).
GET /v1/jobs List past merge jobs (requires database).
GET /v1/audit Service audit log (requires database).

Quick start

# Merge a plain-text template
curl -X POST http://localhost:8080/v1/merge \
  -H "Content-Type: application/json" \
  -d '{
    "name":    "hello.txt",
    "format":  "txt",
    "content": "'$(echo -n "Hello [* name *]!" | base64)'",
    "data":    { "name": "World" }
  }'