Templates
Templates let you create reusable email layouts with dynamic variable substitution. Use {{variableName}} syntax in both the subject and HTML body.
Endpoints
GET/api/templates
POST/api/templates
GET/api/templates/:id
PUT/api/templates/:id
DELETE/api/templates/:id
Create a Template
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | Required | Template name for reference |
| subject | string | Required | Email subject (supports {{variables}}) |
| html | string | Required | HTML content (supports {{variables}}) |
Create template
curl -X POST https://fwd.sarthak.online/api/templates \
-H "Cookie: your-session-cookie" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Email",
"subject": "Welcome, {{name}}!",
"html": "<h1>Hello {{name}}</h1><p>Welcome to {{company}}.</p>"
}'Auto-detected variables
Variables are automatically extracted from your subject and HTML content. Any
{{variableName}} patterns are detected and stored with the template.Variable Substitution
When sending emails with a template, pass a variables object to replace placeholders with actual values.
Send with template variables
// POST /api/send
{
"to": "user@example.com",
"templateId": "tmpl_abc123",
"variables": {
"name": "Sarah",
"company": "Acme Inc"
}
}The above request with the “Welcome Email” template would produce:
- Subject:
Welcome, Sarah! - Body:
<h1>Hello Sarah</h1><p>Welcome to Acme Inc.</p>
Update a Template
Update template
curl -X PUT https://fwd.sarthak.online/api/templates/tmpl_abc123 \
-H "Cookie: your-session-cookie" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Email v2",
"subject": "Welcome aboard, {{name}}!",
"html": "<h1>Hey {{name}}!</h1><p>We are glad to have you.</p>"
}'Delete a Template
Delete template
curl -X DELETE https://fwd.sarthak.online/api/templates/tmpl_abc123 \
-H "Cookie: your-session-cookie"Plan Limits
| Plan | Templates |
|---|---|
| Free | 5 |
| Pro | Unlimited |