Templates
Create reusable email templates with dynamic merge tags.
Create a template
curl -X POST https://api.grosend.com/api/v1/templates \
-H "Authorization: Bearer sv_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Email",
"subject": "Welcome {{name}}!",
"htmlBody": "<h1>Welcome {{name}}</h1><p>Thanks for joining {{company}}.</p>",
"variables": ["name", "company"]
}'
The template body uses {{variable}} syntax. All variables are HTML-escaped by default.
Use a template in an email
curl -X POST https://api.grosend.com/api/v1/emails \
-H "Authorization: Bearer sv_live_..." \
-H "Content-Type: application/json" \
-d '{
"from": "hello@yourdomain.com",
"to": ["user@example.com"],
"template_id": "template-uuid",
"variables": {
"name": "Alice",
"company": "Acme Inc"
}
}'
List templates
curl https://api.grosend.com/api/v1/templates \
-H "Authorization: Bearer sv_live_..."
Update a template
curl -X PUT https://api.grosend.com/api/v1/templates/{template-id} \
-H "Authorization: Bearer sv_live_..." \
-H "Content-Type: application/json" \
-d '{"name": "Updated Name", "subject": "New subject"}'
Delete a template
curl -X DELETE https://api.grosend.com/api/v1/templates/{template-id} \
-H "Authorization: Bearer sv_live_..."