Templates

Templates are reusable email layouts that separate design from content. Create a template once, then reference it when sending broadcasts. Templates support dynamic variables for personalisation.

Create a template

POST
/v1/templates

Create a new template in draft status.

Request body

ParameterTypeDescription
namerequiredstringInternal name for the template.
htmlstringHTML email body with template variables.
textstringPlain text version.
cURL
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}}."
  }'
Response — 201 Created
{
  "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

GET
/v1/templates

List all templates for the current team.

Example Response
{
  "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

GET
/v1/templates/{id}

Retrieve a template by ID, including the full HTML and text content.

Update a template

PATCH
/v1/templates/{id}

Update a template. Set status to published to make it available for use.

Request body

ParameterTypeDescription
namestringTemplate name.
htmlstringHTML email body.
textstringPlain text version.
statusstringSet to published to publish the template, or draft to unpublish.

Delete a template

DELETE
/v1/templates/{id}

Delete a template.

Template status

ParameterTypeDescription
draftstatusTemplate is being edited. Cannot be used in broadcasts.
publishedstatusTemplate is live and available for use.

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.

ParameterTypeDescription
{{first_name}}variableContact first name.
{{last_name}}variableContact last name.
{{email}}variableContact email address.
{{unsubscribe_url}}variableOne-click unsubscribe link (auto-generated).
{{company_name}}variableYour team name from account settings.
{{custom.*}}variableAny custom property from the contact record or send-time data.