MisarMisar Docs
MisarMailMisarBlogMisarReachMisarPostMisarDevMisarCoderMisarSEOMisar PlatformMisar SSO
API Reference

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

MethodPathDescription
GET/api/v1/templatesList templates (paginated)
POST/api/v1/templatesCreate a template
POST/api/v1/templates/renderRender template with merge tag data

List templates

GET/mail/v1/templates

List all templates for the authenticated account.

Query parameters

pagenumberquerydefault: 1

Page number.

limitnumberquerydefault: 20

Results per page (max 50).

typestringquery

Filter by template type: marketing, transactional, or automation.

Response fields

successboolean

true 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.

paginationobject

Pagination metadata: page, limit, total, totalPages.

Request
curl "https://api.misar.io/mail/v1/templates?page=1&limit=20&type=marketing" \
  -H "Authorization: Bearer msk_YOUR_API_KEY"
200 — OK
{
  "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

POST/mail/v1/templates

Create a new reusable template.

Request body

namestringbodyrequired

Internal template name (max 100 characters).

descriptionstringbody

Optional description (max 1000 characters).

subjectstringbodyrequired

Email subject line — supports merge tags (max 255 characters).

bodyHtmlstringbodyrequired

HTML email body — supports merge tags (max 500,000 characters).

bodyTextstringbody

Plain text fallback — recommended.

templateTypestringbodydefault: marketing

Template type: marketing, transactional, or automation.

variablesstring[]body

Declared merge-tag variable names (max 100).

Response fields

successboolean

true when the template was created.

dataobject

The created template row, including id, name, subject, template_type, variables, and created_at.

Request
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"]
  }'
201 — Created
{
  "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

CodeReason
403Template quota reached for your plan (Free: 5 max)
400Missing required fields

Render a template

POST/mail/v1/templates/render

Preview a template rendered with contact or custom merge tag values.

Request body

template_idUUIDbodyrequired

Template to render.

variablesRecord<string, string>body

Key-value pairs for merge tag substitution. Defaults to an empty object.

Response fields

successboolean

true when the template was rendered.

dataobject

Rendered result: subject, html, text, templateId, templateName, and an optional warning.

Request
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"
    }
  }'
200 — OK
{
  "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.

TagExample 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.