Templates
Create and manage reusable email templates with merge tag support
Templates are reusable email designs that support merge tags for personalization. Use them in campaigns, automations, and direct API sends.
Authentication
All template endpoints require an API key. Base URL: https://api.misar.io/mail.
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/v1/templates | List templates (paginated) |
POST | /api/v1/templates | Create a template |
POST | /api/v1/templates/render | Render template with merge tag data |
List templates
/mail/v1/templatesList all templates for the authenticated account.
Query parameters
pagenumberquerydefault: 1Page number.
limitnumberquerydefault: 20Results per page (max 50).
typestringqueryFilter by template type: marketing, transactional, or automation.
Response fields
successbooleantrue when the request succeeded.
dataArray<Template>The page of templates. Each template includes id, name, description, subject, template_type, variables, created_at, and updated_at.
paginationobjectPagination metadata: page, limit, total, totalPages.
curl "https://api.misar.io/mail/v1/templates?page=1&limit=20&type=marketing" \
-H "Authorization: Bearer msk_YOUR_API_KEY"{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Welcome Email",
"description": "Onboarding welcome message",
"subject": "Welcome to {{company_name}}, {{first_name}}!",
"template_type": "marketing",
"variables": ["first_name", "company_name"],
"created_at": "2026-03-01T10:00:00Z",
"updated_at": "2026-03-15T14:30:00Z"
}
],
"pagination": { "page": 1, "limit": 20, "total": 45, "totalPages": 3 }
}Create a template
/mail/v1/templatesCreate a new reusable template.
Request body
namestringbodyrequiredInternal template name (max 100 characters).
descriptionstringbodyOptional description (max 1000 characters).
subjectstringbodyrequiredEmail subject line — supports merge tags (max 255 characters).
bodyHtmlstringbodyrequiredHTML email body — supports merge tags (max 500,000 characters).
bodyTextstringbodyPlain text fallback — recommended.
templateTypestringbodydefault: marketingTemplate type: marketing, transactional, or automation.
variablesstring[]bodyDeclared merge-tag variable names (max 100).
Response fields
successbooleantrue when the template was created.
dataobjectThe created template row, including id, name, subject, template_type, variables, and created_at.
curl -X POST https://api.misar.io/mail/v1/templates \
-H "Authorization: Bearer msk_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Email",
"description": "Onboarding welcome message",
"subject": "Welcome to {{company_name}}, {{first_name}}!",
"bodyHtml": "<h1>Hi {{first_name}},</h1><p>Welcome aboard!</p>",
"bodyText": "Hi {{first_name}}, Welcome aboard!",
"templateType": "marketing",
"variables": ["first_name", "company_name"]
}'{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Welcome Email",
"subject": "Welcome to {{company_name}}, {{first_name}}!",
"template_type": "marketing",
"variables": ["first_name", "company_name"],
"created_at": "2026-04-06T12:00:00Z"
}
}Errors
| Code | Reason |
|---|---|
403 | Template quota reached for your plan (Free: 5 max) |
400 | Missing required fields |
Render a template
/mail/v1/templates/renderPreview a template rendered with contact or custom merge tag values.
Request body
template_idUUIDbodyrequiredTemplate to render.
variablesRecord<string, string>bodyKey-value pairs for merge tag substitution. Defaults to an empty object.
Response fields
successbooleantrue when the template was rendered.
dataobjectRendered result: subject, html, text, templateId, templateName, and an optional warning.
curl -X POST https://api.misar.io/mail/v1/templates/render \
-H "Authorization: Bearer msk_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"template_id": "550e8400-e29b-41d4-a716-446655440000",
"variables": {
"first_name": "Gulshan",
"last_name": "Yadav",
"email": "gulshan@example.com",
"company_name": "Misar AI"
}
}'{
"success": true,
"data": {
"subject": "Welcome to Misar AI, Gulshan!",
"html": "<h1>Hi Gulshan,</h1><p>Welcome aboard!</p>",
"text": "Hi Gulshan, Welcome aboard!",
"templateId": "550e8400-e29b-41d4-a716-446655440000",
"templateName": "Welcome Email"
}
}Errors
404— Template not found
Merge Tag Syntax
Use {{variable_name}} in subject and body fields. Unresolved tags are replaced with an empty string.
| Tag | Example Output |
|---|---|
{{first_name}} | Gulshan |
{{last_name}} | Yadav |
{{email}} | gulshan@example.com |
{{company_name}} | Misar AI |
{{unsubscribe_url}} | Auto-injected footer link |
{{unsubscribe_url}} is automatically appended to all marketing emails as required by CAN-SPAM. It cannot be removed from outbound campaigns.