Automation templates API – Cordial Knowledge Base
How can we help?
Overview
An automation template instance within the automation templates collection contains the essential information to define a template for an automated message. Templates include details for content, channel, message classification (transactional or promotional), subject line, from and reply address, and HTML. You can use a template one or more times.
Additional information
- Template key values must be unique. Therefore, it's important to consider a naming convention that will accommodate creating multiple templates over time. For example:
sports_newsletter_Jan_2025_week1is better thanjan_newsletter. - Cordial provides a default transport for sending communications; however it is possible to use an external provider if needed.
- By default, results data is aggregated on a daily interval. This can be optionally set to hourly if further granularity is needed.
Authentication
Cordial's core APIs use HTTPS Basic Authentication (BA). From within the Cordial platform, you can generate an encoded API key for your account and use it for authorization.
Methods, parameters, and examples
- POST/v2/automationtemplates
- GET/v2/automationtemplates
- GET/v2/automationtemplates/{key}
- PUT/v2/automationtemplates/{key}
- PUT/v2/automationtemplates/{key}/publish
- POST/v2/automationtemplates/{key}/senddraft
- POST/v2/automationtemplates/{key}/send
- DELETE/v2/automationtemplates/{key}
- GET/v2/automationtemplates/{key}/renderdraft/{contactID}
- GET/v2/automationtemplates/{key}/renderpublished/{contactID}
| Method | URL Path |
|---|---|
| POST | /v2/automationtemplates |
| - Creates a new message automation template in the Cordial database using the appropriate JSON body. - Posting more than one time for the same template key value will generate an error. Use the PUT method to change or update fields once the template is created. |
Required
| Parameter | Type | Description | Example |
|---|---|---|---|
| ### Template information | |||
| * key | string | Unique value assigned to the template. The key may only contain letters, numbers, and dashes. | news-01-21-2025 |
| * name | string | A name given to the automation template. | news-01-21-2025 |
| * channel | string | Messaging channel key (e.g. email, sms, push). Note that some of your channels may have custom keys. | |
| * classification | string | If applicable, classifies the message as transactional or promotional. | transactional |
| * baseAggregation | string | Message performance aggregate rollup interval. Specific to API and event triggered messages. Possible values: daily, hourly. |
daily |
| tags | array | An array of string values to identify and categorize the message. Tags are case sensitive. | ["birthday","promo"] |
| transportID | string | Defines the transportID if overriding the default. | trans_1134 |
| draftContent | string | Determines if the message will be submitted as a draft or published version. Default is false (published). Possible values: true, false | true |
| trackLinks | string | Determines if link performance will be tracked. Default is enabled. Possible values: enabled, disabled | disabled |
| ### Message headers (email) | |||
| * subject | string | The subject line for the communication. | Welcome! |
| * fromEmail | string | The email address that the message is from. | email@example.com |
| * fromDesc | string | Describes the sender. | CS Dept |
| * replyEmail | string | Email address that will receive the message replies. | email@example.com |
| ### Message content | |||
| * text/html | string | Message content. Can contain HTML markup for email messages or plain text for SMS. | content |
Examples
The following will create a new message automation template for a promotional email message.
{
"key": "promo_01_20_2025",
"name": "promo_01_20_2025",
"channel": "email",
"classification": "promotional",
"baseAggregation": "hourly",
"message": {
"headers": {
"subject": "One Day Only Sale",
"fromEmail": "info@example.com",
"replyEmail": "info@example.com",
"fromDesc": "Promotions Team"
},
"content": {
"text/html": "<div>Hello World</div>"
}
}
}
SMS
The following will create a new message automation template for a promotional SMS message.
{
"key": "sms_cyber_promo",
"baseAggregation": "daily",
"channel": "sms",
"classification": "promotional",
"name": "Cyber Monday Deal",
"tags": ["cyber_monday", "cm_promo"],
"message": {
"content": {
"text": "SMS text message content"
}
}
}
GET/v2/automationtemplates
| Method | URL Path |
|---|---|
| GET | /v2/automationtemplates |
Retrieves all automation templates from the Cordial database. Response data can be filtered using template fields, message tags, and timestamp values. |
Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| fields | string | Limits the data returned to the fields specified. Multiple fields are comma separated. Possible Values: key, name, classification, channel, stats, baseAggregation, createdAt, lastUpdate, message, mdtID. |
<br>?fields=key%2ClastUpdate<br> |
| ct[gt] | string | Returns records where the create date is greater than the specified date. | <br>?ct%5Bgt%5D=2025-01-01T00:00:00.000Z<br> |
| ct[gte] | string | Returns records where the create date is greater than or equal to the specified date. | <br>?ct%5Bgte%5D=2025-01-01T00:00:00.000Z<br> |
| ct[lt] | string | Returns records where the create date is less than the specified date. | <br>?ct%5Blt%5D=2025-01-01T00:00:00.000Z<br> |
| ct[lte] | string | Returns records where the create date is less than or equal to the specified date. | <br>?ct%5Blte%5D=2025-01-01T00:00:00.000Z<br> |
| lm[gt] | string | Returns records where the last modified time is greater than the specified date. | <br>?lm%5Bgt%5D=2025-01-01T00:00:00.000Z<br> |
| lm[gte] | string | Returns records where the last modified time is greater than or equal to the specified date. | <br>?lm%5Bgte%5D=2025-01-01T00:00:00.000Z<br> |
| lm[lt] | string | Returns records where the last modified time is less than the specified date. | <br>?lm%5Blt%5D=2025-01-01T00:00:00.000Z<br> |
| lm[lte] | string | Returns records where the last modified time is less than or equal to the specified date. | <br>?lm%5Blte%5D=2025-01-01T00:00:00.000Z<br> |
| tags | string | Returns automation templates that contain the specified message tags. Multiple tags are comma separated. | <br>?tags=welcome%2C%20promo<br> |
| page | string | Specifies the results page number to be returned. | <br>?page=3<br> |
| per_page | string | Specifies the number of records returned per page. | <br>?per_page=100<br> |
DELETE/v2/automationtemplates/{key}
| Method | URL Path |
|---|---|
| DELETE | /v2/automationtemplates/{key} |
| - Deletes an existing automation template within the Cordial database. - The automation template is defined by the template's unique key value. For example, /automationtemplate/sports_newsletter_Jan_2025_week1 would delete the template with the key value of "sports_newsletter_Jan_2025_week1". |
Error Responses
The Cordial API will return an error object with an errorKey and message if there is a problem with an API call. Below is a list of errors specific to the Automation Templates API endpoint, along with suggested modifications to resolve each error. If you receive an error from this API endpoint that is not listed in this table, it is likely recorded within the Global API Error Responses.