Templates
Templates are reusable email layouts that separate design from content. Create a template once, then reference it when sending transactional emails or broadcasts. Templates support dynamic variables for personalisation.
Create a template
/v1/templatesCreate a new template in draft status.
Request body
| Parameter | Type | Description |
|---|---|---|
namerequired | string | Internal name for the template. |
subjectrequired | string | Default subject line. Supports template variables. |
htmlrequired | string | HTML email body with template variables. |
text | string | Plain text version. Auto-generated from HTML if omitted. |
curl -X POST https://api.txtly.com.au/v1/templates \\
-H "Authorization: Bearer tx_your_api_key" \\
-H "Content-Type: application/json" \\
-d '{
"name": "Welcome Email",
"subject": "Welcome to {{company_name}}, {{first_name}}!",
"html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>"
}'{
"id": "tmpl_abc123",
"name": "Welcome Email",
"subject": "Welcome to {{company_name}}, {{first_name}}!",
"status": "draft",
"created_at": "2026-03-21T00:00:00Z"
}List templates
/v1/templatesList all templates for the current team.
Get a template
/v1/templates/{id}Retrieve a template by ID, including the full HTML and text content.
Update a template
/v1/templates/{id}Update a template. Only draft templates can be edited directly.
Delete a template
/v1/templates/{id}Delete a template. Templates in use by active workflows cannot be deleted.
Publish a template
/v1/templates/{id}/publishPublish a draft template, making it available for use in emails, broadcasts, and workflows.
Template status
| Parameter | Type | Description |
|---|---|---|
draft | status | Template is being edited. Cannot be used in emails or broadcasts. |
published | status | Template is live and available for use. Edits create a new draft version. |
Template variables
Use double curly braces to insert dynamic values into your templates. Variables are replaced at send time with contact properties or custom data passed in the API call.
| Parameter | Type | Description |
|---|---|---|
{{first_name}} | variable | Contact first name. |
{{last_name}} | variable | Contact last name. |
{{email}} | variable | Contact email address. |
{{unsubscribe_url}} | variable | One-click unsubscribe link (auto-generated). |
{{company_name}} | variable | Your team name from account settings. |
{{custom.*}} | variable | Any custom property from the contact record or send-time data. |
Using templates when sending
Reference a template by ID when sending an email. You can override the subject and pass additional variables:
{
"from": "hello@yourdomain.com",
"to": "user@example.com",
"template_id": "tmpl_abc123",
"data": {
"first_name": "Alice",
"company_name": "Acme Inc"
}
}