Skip to main content

Message Templates

Message templates allow you to create reusable text templates for delivery across multiple channels: SMS, WhatsApp, Telegram and Signal. They are managed through the dashboard and include variable injection for personalized messaging.

Creating Message Templates

POST /message-templates
Content-Type: application/json
Authorization: Bearer {your-jwt-token}

{
"projectId": "project-uuid",
"name": "welcome-message",
"body": "Hi {{firstName}}, welcome to {{appName}}! Your verification code is {{code}}."
}

Response:

{
"id": "message-template-uuid",
"name": "welcome-message",
"body": "Hi {{firstName}}, welcome to {{appName}}! Your verification code is {{code}}.",
"projectId": "project-uuid",
"createdAt": "2024-01-01T10:00:00Z"
}

Template Variables

Message templates support the same Handlebars variable injection as email templates.

Get Template Variables

GET /message-templates/{templateId}/variables
Authorization: Bearer {your-jwt-token}

Response:

{
"variables": ["firstName", "appName", "code"]
}

Template Preview

Preview a message template with actual variable values:

POST /message-templates/preview
Content-Type: application/json
x-api-key: {your-api-key}

{
"templateId": "message-template-uuid",
"projectId": "project-uuid",
"variables": {
"firstName": "John",
"appName": "MyApp",
"code": "123456"
}
}

The projectId is required when authenticating with a JWT token instead of an API key.

Response:

{
"renderedMessage": "Hi John, welcome to MyApp! Your verification code is 123456."
}

Managing Message Templates

Get All Message Templates

Supports optional filtering by project and pagination:

GET /message-templates?projectId={projectId}&page=1&limit=20
Authorization: Bearer {your-jwt-token}
Query ParamRequiredDescription
projectIdNoFilter templates by project
pageNoPage number for pagination
limitNoItems per page (max: 100)

Get Project Message Templates

GET /message-templates/project/{projectId}?page=1&limit=20
Authorization: Bearer {your-jwt-token}

Get Specific Message Template

GET /message-templates/{templateId}
Authorization: Bearer {your-jwt-token}

Update Message Template

PUT /message-templates/{templateId}
Content-Type: application/json
x-api-key: {your-api-key}

{
"name": "updated-welcome-message",
"body": "Updated message content with {{variables}}."
}

Delete Message Template

DELETE /message-templates/{templateId}
Authorization: Bearer {your-jwt-token}

Import & Export Templates

Export all message templates from a project and import them into another. Useful for copying templates across environments.

Export Templates

GET /message-templates/export/{projectId}
Authorization: Bearer {your-jwt-token}

Response:

{
"templates": [...],
"exportedAt": "2024-01-01T10:00:00Z",
"projectId": "project-uuid",
"projectName": "My Project",
"totalTemplates": 3
}

Import Templates

POST /message-templates/import/{projectId}
Content-Type: multipart/form-data
Authorization: Bearer {your-jwt-token}

file: <exported-message-templates.json>

Best Practices

  • Keep message bodies concise, especially for SMS delivery
  • Test with preview to verify variable substitution before sending
  • Use clear, actionable language
  • Be mindful of character limits for SMS channels
  • Use import/export to replicate templates across staging and production projects