# Email Templates
Email Templates hold the subject line and HTML body that an Email Campaign uses when it sends to a Campaign Subscriber.
# Body syntax
The HTML body supports a strict subset of Mustache (opens new window):
{{variable}}for printing Campaign Subscriber'svariables{{#variable}} ... {{/variable}}for "if not empty" sections{{^variable}} ... {{/variable}}for "if empty" sections
# Built-in variables
These variables are built-in and available automatically:
| Variable | Value |
|---|---|
{{customer_first_name}} | The customer's first name. |
{{customer_last_name}} | The customer's last name. |
{{current_balance}} | The debt account's current balance prefixed with a dollar sign ($). |
{{external_id}} | The debt account's debt_account_external_id. |
{{portal_url}} | The payment portal url. |
{{campaign_unsubscribe_url}} | The unsubscribe url. |
# Create Email Template
POST https://<org-uuid>.production.tratta.io/api/v1/email-templates
curl https://<org-uuid>.production.tratta.io/api/v1/email-templates \
-H "Authorization: Bearer eyJ0eXA3asdk..." \
-d subject="Your offers are ready" \
-d body="<html><head></head><body><p>Hello {{customer_first_name}}</p><p>Balance: {{current_balance}}</p></body></html>"
# Parameters
subject required|string|max:255
The email subject line. Used as-is, variables are not supported.
body required|string
The HTML body of the email. Supports a strict subset of Mustache (opens new window) tags:
{{variable}}for printing variables{{#variable}} ... {{/variable}}for "if not empty" sections{{^variable}} ... {{/variable}}for "if empty" sections
# Returns
A json with data property that contains created email template object.
{
"id": "uuid",
"subject": "string",
"body": "string",
"created_at": "timestamp"
}
# Get Email Template
GET https://<org-uuid>.production.tratta.io/api/v1/email-templates/{id}
curl https://<org-uuid>.production.tratta.io/api/v1/email-templates/{id} \
-H "Authorization: Bearer eyJ0eXA3asdk..."Returns 404 if no template matches the uuid.
# Returns
A json with data property that contains created email template object.
{
"id": "uuid",
"subject": "string",
"body": "string",
"created_at": "timestamp"
}
# List Email Templates
GET https://<org-uuid>.production.tratta.io/api/v1/email-templates
curl https://<org-uuid>.production.tratta.io/api/v1/email-templates \
-H "Authorization: Bearer eyJ0eXA3asdk..."# Parameters
limit optional|integer|min:1|max:200
Page size. Defaults to 25. Returns a paginated list ordered by newest first.
page optional|integer
Page number for pagination. Defaults to 1.
# Returns
A json with data property that contains array of email template objects.
{
"id": "uuid",
"subject": "string",
"body": "string",
"created_at": "timestamp"
}
# Update Email Template
PUT https://<org-uuid>.production.tratta.io/api/v1/email-templates/{id}
curl https://<org-uuid>.production.tratta.io/api/v1/email-templates/{id} \
-H "Authorization: Bearer eyJ0eXA3asdk..." \
-d subject="New subject line" \
-X PUT
# Parameters
subject optional|string|max:255
New subject line.
body optional|string
New HTML body.
# Returns
A json with data property that contains created email template object.
{
"id": "uuid",
"subject": "string",
"body": "string",
"created_at": "timestamp"
}
# Delete Email Template
DELETE https://<org-uuid>.production.tratta.io/api/v1/email-templates/{id}
curl https://<org-uuid>.production.tratta.io/api/v1/email-templates/{id} \
-H "Authorization: Bearer eyJ0eXA3asdk..." \
-X DELETE
Returns 409 Conflict if the template is still attached to an Email Campaign; detach it by deleting or updating those campaigns first, then retry.
# Returns
{
"success": "boolean"
}