What Is a Template?
A template is a reusable email design. It contains:
- Structure - Sections, layouts, components
- Content - Text, images, buttons
- Variables - Dynamic placeholders for personalization
- Styling - Colors, fonts, spacing
Templates are rendered with variables to produce final HTML.
Template Document Model
Internally, templates are stored as a document structure:
type EmailDocument = {
id: string
name: string
subject?: string
sections: Section[]
styles: DocumentStyles
}
Each section contains content blocks, and blocks can contain text with variables.
Template Components
Sections
Top-level containers that stack vertically:
- Header section
- Content sections
- Footer section
Sections have their own background colors and padding.
Blocks
Content within sections:
- Text - Paragraphs, headings, lists
- Image - With alt text and links
- Button - Call-to-action with URL
- Divider - Horizontal separator
- Spacer - Vertical spacing
Layouts
Multi-column arrangements within sections:
- Single column (default)
- Two columns
- Three columns
Columns automatically stack on mobile.
Template Lifecycle
Create → Edit → Save → Render → Send
- Create - New template in a project
- Edit - Build in visual editor
- Save - Stored in database
- Render - Hydrate with variables
- Send - Deliver via provider
Template vs Rendered Email
| Template | Rendered Email |
|---|---|
Has {{variables}} | Variables replaced with values |
| Design-time | Send-time |
| Stored in database | Generated on demand |
| Editable | Read-only output |
Subject Lines
Templates can have a subject:
- Set in the template editor
- Can include variables:
Your order {{orderNumber}} shipped - Can be overridden via
_subjectin API
Subject priority:
_subjectfrom API request- Template subject
- Template name (fallback)
Template Storage
Templates are stored per-user:
- Each template belongs to a project
- Projects belong to users
- Templates are identified by unique IDs
Template IDs
Template IDs look like: tmpl_abc123xyz
Use these IDs when:
- Calling the render API
- Calling the execute flow API
- Referencing templates in code
Find template IDs in:
- The URL when editing:
/editor/template/tmpl_abc123xyz - The template settings panel
Template Limits
| Plan | Templates per Project | Projects |
|---|---|---|
| Free | 10 | 3 |
| Pro | 100 | Unlimited |
| Team | Unlimited | Unlimited |
Template Best Practices
Naming
Use descriptive, consistent names:
welcome-emailorder-confirmationpassword-reset
Organization
Group related templates in projects:
- Auth - Welcome, verify, reset
- Orders - Confirmation, shipped, delivered
- Notifications - Comment, mention, digest
Versioning
mailshit doesn’t have built-in versioning, but you can:
- Duplicate templates before major changes
- Name versions:
welcome-email-v2 - Keep old templates for rollback
Reusability
Design templates to be reusable:
- Use variables for all dynamic content
- Set sensible defaults
- Avoid hardcoded values