SMS Templates
SMS templates allow you to create reusable text message templates with variable injection for personalized SMS messaging.
Creating SMS Templates
Create a new SMS template:
POST /sms-templates
Content-Type: application/json
Authorization: Bearer {your-jwt-token}
{
"projectId": "project-uuid",
"name": "welcome-sms",
"body": "Hi {{firstName}}, welcome to {{appName}}! Your verification code is {{code}}."
}
Response:
{
"id": "sms-template-uuid",
"name": "welcome-sms",
"body": "Hi {{firstName}}, welcome to {{appName}}! Your verification code is {{code}}.",
"projectId": "project-uuid",
"createdAt": "2024-01-01T10:00:00Z"
}
Template Variables
SMS templates support the same variable injection as email templates.
Get Template Variables
GET /sms-templates/{templateId}/variables
Authorization: Bearer {your-jwt-token}
Response:
{
"variables": ["firstName", "appName", "code"]
}
Template Preview
Preview SMS templates with variables:
POST /sms-templates/preview
Content-Type: application/json
x-api-key: {your-api-key}
{
"templateId": "sms-template-uuid",
"variables": {
"firstName": "John",
"appName": "MyApp",
"code": "123456"
}
}
Response:
{
"renderedMessage": "Hi John, welcome to MyApp! Your verification code is 123456."
}
Managing SMS Templates
Get All SMS Templates
GET /sms-templates
Authorization: Bearer {your-jwt-token}
Get Project SMS Templates
GET /sms-templates/project/{projectId}
Authorization: Bearer {your-jwt-token}
Get Specific SMS Template
GET /sms-templates/{templateId}
Authorization: Bearer {your-jwt-token}
Update SMS Template
PUT /sms-templates/{templateId}
Content-Type: application/json
x-api-key: {your-api-key}
{
"name": "updated-welcome-sms",
"body": "Updated message content with {{variables}}."
}
Delete SMS Template
DELETE /sms-templates/{templateId}
Authorization: Bearer {your-jwt-token}
SMS Best Practices
- Use clear, actionable language
- Test with preview to ensure proper variable substitution