Templates
Create, manage, and render reusable email templates with variable substitution.
Templates
Base: https://api.misar.io/mail/v1/templates
Required scope: write / read
List templates
GET /v1/templates
Query params: type (marketing|transactional), page, limit.
Get template
GET /v1/templates/:id
Create template
POST /v1/templates
{
"name": "Order Confirmation",
"type": "transactional",
"subject": "Your order #{{order_id}} is confirmed",
"html": "<h1>Hi {{first_name}},</h1><p>Order <strong>#{{order_id}}</strong> confirmed. Total: {{total}}</p>",
"text": "Hi {{first_name}}, Order #{{order_id}} confirmed. Total: {{total}}",
"variables": ["first_name", "order_id", "total"]
}
Fields
| Field | Type | Required | Description |
|-------|------|----------|-------------|
| name | string | ✅ | Template display name |
| type | string | ✅ | marketing | transactional |
| subject | string | ✅ | Subject line (supports {{variables}}) |
| html | string | ✅ | HTML body with {{variable}} placeholders |
| text | string | — | Plain-text fallback |
| variables | array | — | Declared variable names for validation |
| preheader | string | — | Inbox preview text |
Update template
PATCH /v1/templates/:id
Delete template
DELETE /v1/templates/:id
Preview template
Render a template with test variable values (returns HTML string, does not send):
POST /v1/templates/:id/preview
{
"variables": {
"first_name": "Alice",
"order_id": "1234",
"total": "$49.00"
}
}
Response:
{
"success": true,
"html": "<h1>Hi Alice,</h1><p>Order <strong>#1234</strong> confirmed. Total: $49.00</p>",
"text": "Hi Alice, Order #1234 confirmed. Total: $49.00",
"subject": "Your order #1234 is confirmed"
}
Render template
Render without a saved template ID (inline render):
POST /v1/templates/render
{
"html": "<p>Hello {{name}}!</p>",
"subject": "Hello {{name}}",
"variables": { "name": "Alice" }
}
Use a template in a send
Pass templateId and variables to /v1/send:
{
"from": { "email": "[email protected]" },
"to": [{ "email": "[email protected]" }],
"templateId": "tmpl_01ABCDEF",
"variables": {
"first_name": "Alice",
"order_id": "5678",
"total": "$99.00"
}
}