Skip to content

Email Templates

Create reusable email templates with dynamic variable substitution. Templates save you from sending the same HTML on every request.

Create a Template

POST /v1/email/templates

Request Body

ParameterTypeRequiredDescription
namestringYesInternal name for this template (e.g., "welcome_email").
subjectstringYesEmail subject. Supports {{variable}} syntax.
body_htmlstringYesHTML body. Use {{variable_name}} for dynamic content.
body_textstringNoPlain-text fallback.
variablesarrayNoList of expected variable names (for documentation).
bash
curl -X POST https://sendapi.co/v1/email/templates \
  -H "Authorization: Bearer sk_live_123456789" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "welcome_email",
    "subject": "Welcome to {{app_name}}, {{user_name}}!",
    "body_html": "<h1>Welcome, {{user_name}}!</h1><p>Your account is ready. <a href=\"{{login_url}}\">Log in now →</a></p>",
    "variables": ["user_name", "app_name", "login_url"]
  }'
javascript
const template = await client.email.templates.create({
  name: 'welcome_email',
  subject: 'Welcome to {{app_name}}, {{user_name}}!',
  body_html: '<h1>Welcome, {{user_name}}!</h1><p><a href="{{login_url}}">Log in now</a></p>',
  variables: ['user_name', 'app_name', 'login_url']
});

Response

json
{
  "id": "tpl_01H9...AB",
  "name": "welcome_email",
  "subject": "Welcome to {{app_name}}, {{user_name}}!",
  "variables": ["user_name", "app_name", "login_url"],
  "created_at": "2026-03-09T14:30:00Z"
}

Send Using a Template

Use the template ID when calling /v1/email/send:

json
{
  "to": "alice@example.com",
  "template_id": "tpl_01H9...AB",
  "variables": {
    "user_name": "Alice",
    "app_name": "MyApp",
    "login_url": "https://myapp.com/login"
  }
}

List Templates

GET /v1/email/templates

bash
curl https://sendapi.co/v1/email/templates \
  -H "Authorization: Bearer sk_live_123456789"

Update a Template

PUT /v1/email/templates/{id}

bash
curl -X PUT https://sendapi.co/v1/email/templates/tpl_01H9...AB \
  -H "Authorization: Bearer sk_live_123456789" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Welcome aboard, {{user_name}}!"}'

Delete a Template

DELETE /v1/email/templates/{id}

bash
curl -X DELETE https://sendapi.co/v1/email/templates/tpl_01H9...AB \
  -H "Authorization: Bearer sk_live_123456789"

In Use

Deleting a template that is actively referenced by scheduled sends will not cancel those sends — the snapshot of the template at send time is used.

Variable Syntax

Templates use {{double_curly_braces}} for variables. Variables are HTML-escaped by default to prevent XSS. Use {{{triple_braces}}} to render raw HTML.

Released under the MIT License.