Templates
Templates are reusable email layouts that separate design from content. Create and publish a template once, then reference it by templateId when sending emails. 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. |
html | string | HTML email body with template variables. |
text | string | Plain text version. |
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",
"html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>",
"text": "Welcome, {{first_name}}! Thanks for joining {{company_name}}."
}'{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Welcome Email",
"html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>",
"text": "Welcome, {{first_name}}! Thanks for joining {{company_name}}.",
"status": "draft",
"createdAt": "2026-03-21T00:00:00Z",
"updatedAt": "2026-03-21T00:00:00Z"
}List templates
/v1/templatesList all templates for the current team.
{
"data": [
{
"id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"name": "Welcome Email",
"status": "draft",
"createdAt": "2026-03-21T00:00:00Z",
"updatedAt": "2026-03-21T00:00:00Z"
}
]
}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. Set status to published to make it available for use.
Request body
| Parameter | Type | Description |
|---|---|---|
name | string | Template name. |
html | string | HTML email body. |
text | string | Plain text version. |
status | string | Set to published to publish the template, or draft to unpublish. |
Delete a template
/v1/templates/{id}Delete a template.
Template status
| Parameter | Type | Description |
|---|---|---|
draft | status | Template is being edited. Sends referencing a draft template are rejected. |
published | status | Template is live and available for use. |
Template variables
Use double curly braces to insert dynamic values into your templates — any variable name works, e.g. {{first_name}} or {{order_id}}. Variables are replaced at send time with the values you pass in the templateVariables object of the send request; substitution applies to the subject line as well as the HTML and text bodies. Placeholders without a matching variable are left as-is.
curl -X POST https://api.txtly.com.au/v1/emails \
-H "Authorization: Bearer tx_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"from": "noreply@example.com",
"to": ["user@example.com"],
"subject": "Welcome, {{first_name}}!",
"templateId": "d290f1ee-6c54-4b01-90e6-d701748f0851",
"templateVariables": {
"first_name": "Alice",
"company_name": "Acme Corp"
}
}'