Templates

Create reusable email templates with dynamic variables.

Creating Templates

Templates can be created in your dashboard or via the API:

POST https://getmailer.co/api/templates
{
  "name": "Welcome Email",
  "subject": "Welcome to {{company}}, {{name}}!",
  "html": "<h1>Hello {{name}}</h1><p>Thanks for joining {{company}}.</p>",
  "text": "Hello {{name}}, Thanks for joining {{company}}."
}

Template Variables

Use double curly braces for variables: {{variableName}}

Simple Variables

Hello {{name}}, your order #{{orderNumber}} is confirmed.

Default Values

Provide fallbacks for optional variables:

Hello {{name | default: 'there'}}

Using Templates

Reference a template by ID when sending an email:

curl -X POST https://getmailer.co/api/emails \
  -H "Authorization: Bearer gm_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "welcome@yourdomain.com",
    "to": "user@example.com",
    "templateId": "tmpl_abc123",
    "variables": {
      "name": "John",
      "company": "Acme Inc",
      "orderNumber": "12345"
    }
  }'

List Templates

GET https://getmailer.co/api/templates
{
  "templates": [
    {
      "id": "tmpl_abc123",
      "name": "Welcome Email",
      "subject": "Welcome to {{company}}, {{name}}!",
      "createdAt": "2024-01-10T10:00:00Z",
      "updatedAt": "2024-01-15T14:30:00Z"
    }
  ]
}

Update Template

PATCH https://getmailer.co/api/templates/:id
{
  "name": "Updated Welcome Email",
  "subject": "Welcome aboard, {{name}}!",
  "html": "<h1>Welcome {{name}}</h1><p>We're excited to have you!</p>"
}

Delete Template

DELETE https://getmailer.co/api/templates/:id

Returns 204 No Content on success.

Related

Templates - GetMailer Docs | GetMailer