Templates

Sometimes it can be more convenient to separate the content of a message from the API call to send it, such as when this is changed often or a non-technical team is responsible for the content.

To do this you can use our Templates feature.


Set up a template

  1. Log in to the portal.

  2. Go to Templates and select Create.


  3. Enter a Template Name.

  4. Optionally, enter a Template ID, or, select the Automatically generate an ID checkbox to have the system generate this for you using the template name.
    The Template ID is used to refer to the template in API calls.

  5. Optionally, enter a Description for the template.


    542

  6. Select Next.


    1203

  7. Add one or more message parts, using text, merge fields and media. Merge fields are populated from the profile data the template is being sent to, or left blank if no data is found.

  8. Select Create to save the template.


Use your templates

To use your templates, add the templateId field to your API call instead of specifying bodies or message parts directly.

📘

Templates or content but not both

You can't use the templateId field as well as the body or messageParts fields in a single API call. You must choose one or the other.

{
  "templateId": "promotion_message",
  "to": {
    "phoneNumber": "44123123123"
  },
  "channelOptions": {
    "sms": {
      "from": "dotdigital"
    }
  },
  "rules": [
    "sms"
  ],
  "metadata": {"data": "My important data"}
}

In addition to using templates with the Enterprise Communications API, templates can also be used in the chat tool for canned responses.