# Template API
> Render templates with your data. Pass a Handlebars or Mustache template plus a JSON data object and get back the rendered text — ideal for dynamic emails, SMS and notifications, document and report generation, code scaffolding, and any "fill in the blanks" output. Handlebars supports blocks like {{#each}} and {{#if}} and is HTML-escaped by default (turn off with escape=false); Mustache is logic-less with sections and inverted sections. Both engines are safe — there is no arbitrary code execution. Pure local rendering — no key, no third-party service, instant. Live. 3 endpoints. Distinct from a Markdown renderer or a fake-data generator.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/template-api/..."
```

## Pricing
- **Free** (Free) — 1,360 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 21,000 calls/Mo, 8 req/s
- **Pro** ($25/Mo) — 168,000 calls/Mo, 20 req/s
- **Mega** ($61/Mo) — 860,000 calls/Mo, 50 req/s

## Endpoints

### Render

#### `GET /v1/render` — Render a template with data

**Parameters:**
- `template` (query, required, string) — Handlebars/Mustache template Example: `Hi {{name}}! {{#each items}}[{{this}}]{{/each}}`
- `data` (query, optional, string) — JSON data object Example: `{"name":"Ada","items":["a","b"]}`
- `engine` (query, optional, string) — handlebars|mustache Example: `handlebars`
- `escape` (query, optional, string) — false to disable HTML-escaping (Handlebars)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/template-api/v1/render?template=Hi+%7B%7Bname%7D%7D%21+%7B%7B%23each+items%7D%7D%5B%7B%7Bthis%7D%7D%5D%7B%7B%2Feach%7D%7D&data=%7B%22name%22%3A%22Ada%22%2C%22items%22%3A%5B%22a%22%2C%22b%22%5D%7D&engine=handlebars"
```

**Response:**
```json
{
    "data": {
        "engine": "handlebars",
        "length": 14,
        "output": "Hi Ada! [a][b]"
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:56.519Z",
        "request_id": "1bb20e13-5cf4-4fb6-a1e7-73286264ff16"
    },
    "status": "ok",
    "message": "Render a template",
    "success": true
}
```

### Reference

#### `GET /v1/engines` — Supported engines

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/template-api/v1/engines"
```

**Response:**
```json
{
    "data": {
        "count": 2,
        "engines": [
            {
                "name": "handlebars",
                "note": "blocks, helpers, partials-free, HTML-escaped by default (escape=false to disable)"
            },
            {
                "name": "mustache",
                "note": "logic-less; sections, inverted sections, HTML-escaped ({{{ }}} for raw)"
            }
        ]
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:56.628Z",
        "request_id": "5b5a3fd5-f715-470b-982a-1f6022b940d3"
    },
    "status": "ok",
    "message": "Supported engines",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/template-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "auth": "none upstream; this gateway requires x-api-key",
        "name": "Template API",
        "note": "Render a template with JSON data. /v1/render?template=...&data={...}&engine=handlebars|mustache (Handlebars supports {{#each}}/{{#if}} blocks and is HTML-escaped by default — escape=false to disable; Mustache is logic-less with sections). Safe templating — no arbitrary code execution. Instant, nothing stored.",
        "source": "Local rendering (Handlebars, Mustache) — no key, no upstream",
        "endpoints": 3
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:56.707Z",
        "request_id": "33f0bae8-a795-42e1-acb2-aac7c25123d1"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/template-api
OpenAPI spec: https://www.oanor.com/api/template-api/openapi.json
