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 namesubject- Email subject line (can include variables)html- Email body with stylingtext- Plain text fallbackvariables- Dynamic content placeholders
Variable Syntax
Use double curly braces for variables in your templates:
<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:
Welcome to {{company}}, {{name}}!Sending with Variables
Pass variable values in the data object:
await sendEmail({ to: '[email protected]', 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:
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:
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 welcomepassword-reset- Password reset requestorder-confirmation- Purchase confirmationinvoice-paid- Payment received
Keep Variables Consistent
Use the same variable names across templates where applicable:
name- Recipient's nameemail- Recipient's emailcompany- Your company namesupportUrl- Link to support
Provide Fallbacks
Handle missing variables gracefully in your templates:
<p>Hello {{name | default: 'there'}}!</p>Test Before Sending
Use test API keys and preview in the dashboard before going live:
# Development environmentARTAMAIL_API_KEY=am_test_sk_xxx# Emails won't actually be sent, but you'll see them in the dashboard