Guide

Email Templates

Create reusable email templates with variable substitution.

Template Basics

Templates are created in the ArtaMail dashboard. Each template has:

  • slug - Unique identifier used in API calls (e.g., "welcome", "password-reset")
  • name - Human-readable name
  • subject - Email subject line (can include variables)
  • html - Email body with styling
  • text - Plain text fallback
  • variables - Dynamic content placeholders

Variable Syntax

Use double curly braces for variables in your templates:

html
<h1>Welcome, {{name}}!</h1>
<p>Thanks for joining {{company}}.</p>
<a href="{{verifyUrl}}">Verify your email</a>

Variables in subject lines work the same way:

text
Welcome to {{company}}, {{name}}!

Sending with Variables

Pass variable values in the data object:

typescript
await sendEmail({
template: 'welcome',
data: {
name: 'John Doe',
company: 'Acme Inc',
verifyUrl: 'https://example.com/verify/abc123'
}
});

Template Categories

Transactional

Triggered by user actions. These are high-priority and always sent:

  • Welcome emails
  • Password reset
  • Order confirmations
  • Account notifications

Marketing

Promotional content that respects unsubscribe preferences:

  • Newsletters
  • Product announcements
  • Promotional offers

Listing Templates

Get available templates via the API:

typescript
const templates = await artamail.listTemplates();
for (const t of templates) {
console.log(`${t.slug}: ${t.name}`);
console.log(' Variables:', t.variables.join(', '));
console.log(' Category:', t.category);
}

Getting Template Details

Check a specific template's requirements:

typescript
const template = await artamail.getTemplate('welcome');
if (template) {
console.log('Subject:', template.subject);
console.log('Required variables:', template.variables);
console.log('Version:', template.version);
} else {
console.log('Template not found');
}

Template Versioning

Each template has a version number that increments when you update it in the dashboard. Emails always use the current version at send time.

Best Practices

Use Descriptive Slugs

  • welcome- New user welcome
  • password-reset- Password reset request
  • order-confirmation- Purchase confirmation
  • invoice-paid- Payment received

Keep Variables Consistent

Use the same variable names across templates where applicable:

  • name- Recipient's name
  • email- Recipient's email
  • company- Your company name
  • supportUrl- Link to support

Provide Fallbacks

Handle missing variables gracefully in your templates:

html
<p>Hello {{name | default: 'there'}}!</p>

Test Before Sending

Use test API keys and preview in the dashboard before going live:

.env.local
# Development environment
ARTAMAIL_API_KEY=am_test_sk_xxx
# Emails won't actually be sent, but you'll see them in the dashboard
Preview tip
Preview templates in the dashboard to see exactly how they'll look with sample data before sending to real users.