Message Templates
Message templates let you define reusable content for both email and SMS channels. Templates support merge fields that are populated with contact and foundation data at send time.
MessageTemplate model
Section titled “MessageTemplate model”| Field | Type | Description |
|---|---|---|
id | UUID | Primary key |
foundation_id | UUID | Owning foundation |
name | string | Template name (e.g., “Donation Thank You”) |
channel | CampaignChannel | email or sms |
subject | string? | Email subject line (null for SMS templates) |
body | string | Message body with merge field placeholders |
merge_fields | JSON? | Metadata about which merge fields are used |
Merge fields
Section titled “Merge fields”Templates support the same merge placeholders used across campaigns and sequences:
- first_name — Contact’s first name (Email, SMS)
- last_name — Contact’s last name (Email, SMS)
- foundation_name — Foundation’s display name (Email, SMS)
Each placeholder is wrapped in double curly braces in your template content.
Merge field replacement happens at send time in the EmailService and SmsService. The merge_fields JSON column on the template stores metadata about which fields the template uses, for UI display purposes.
Email templates
Section titled “Email templates”Email templates include both a subject and body field. The body contains HTML:
{ "name": "Donation Receipt", "channel": "email", "subject": "Thank you for your gift, {{first_name}}!", "body": "<p>Hi {{first_name}},</p><p>Thank you for your generous donation to <strong>{{foundation_name}}</strong>. Your support makes a real difference.</p><p>With gratitude,<br>{{foundation_name}}</p>", "merge_fields": ["first_name", "foundation_name"]}SMS templates
Section titled “SMS templates”SMS templates have a body only (no subject):
{ "name": "Event Reminder", "channel": "sms", "subject": null, "body": "Hi {{first_name}}, reminder: our annual gala is this Saturday at 6pm. We'd love to see you there! - {{foundation_name}}", "merge_fields": ["first_name", "foundation_name"]}Using templates
Section titled “Using templates”Templates are reference content that can be copied into campaigns and sequence steps. When creating a campaign or sequence step, you can start from a template and customize the content.
The body content from a template is used as the starting point — it is copied into the campaign or step, not referenced. Changes to a template do not retroactively affect previously sent messages.
API endpoints
Section titled “API endpoints”| Method | Path | Description |
|---|---|---|
| GET | /api/message-templates | List all templates |
| POST | /api/message-templates | Create a template |
| GET | /api/message-templates/{id} | Show a template |
| PUT | /api/message-templates/{id} | Update a template |
| DELETE | /api/message-templates/{id} | Delete a template |
All endpoints follow Laravel’s apiResource conventions and are scoped to the authenticated user’s foundation.