Email Templates
Email templates in MessagePipe allow you to create reusable HTML email designs with variable injection for personalized messaging.
Creating Email Templates
Using the API
Create a new email template by sending HTML content:
POST /templates?projectId={projectId}&name={templateName}
Content-Type: text/html
Authorization: Bearer {your-jwt-token}
<!DOCTYPE html>
<html>
<head>
<title>Welcome Email</title>
</head>
<body>
<h1>Welcome {{firstName}}!</h1>
<p>Thank you for joining {{companyName}}.</p>
</body>
</html>
Response:
{
"id": "template-uuid",
"name": "welcome-email",
"projectId": "project-uuid",
"createdAt": "2024-01-01T10:00:00Z"
}
Template Variables
Templates support variable injection using double curly braces: {{variableName}}
Retrieving Template Variables
Get all variables used in a template:
GET /templates/variables/{templateId}
Authorization: Bearer {your-jwt-token}
Response:
{
"variables": ["firstName", "companyName", "activationUrl"]
}
Template Preview
Preview how a template looks with actual data:
POST /templates/preview
Content-Type: application/json
x-api-key: {your-api-key}
{
"templateId": "template-uuid",
"variables": {
"firstName": "John",
"companyName": "Nobu"
}
}
Response:
{
"preview": "<h1>Welcome John!</h1><p>Thank you for joining Nobu.</p>"
}
Managing Templates
Get All Templates
GET /templates
Authorization: Bearer {your-jwt-token}
Get Project Templates
GET /templates/project/{projectId}
Authorization: Bearer {your-jwt-token}
Get Specific Template
GET /templates/{templateId}
Authorization: Bearer {your-jwt-token}
Update Template
PUT /templates/{templateId}?name=updated-name
Content-Type: text/html
x-api-key: {your-api-key}
<html>Updated content here</html>
Delete Template
DELETE /templates/{templateId}
Authorization: Bearer {your-jwt-token}
Best Practices
- Use semantic variable names that clearly indicate their purpose
- Test templates with preview before sending
- Keep HTML simple and email-client compatible
- Include fallback text for images and complex styling
- Use descriptive template names for easy identification