API: Rest Create Template

The Create Template command allows you to define and create a new template of content to send to Contacts.  The command allows you to specify several components of a template, such as Subject and Body.  More advanced control of the Template properties must be set through the web interface or WebServices API where available.    

POST /templates

https://[siteurl]/rest/templates

Request Body Parameters

The Create Templates command requires the following in the Posted JSON in order to create a template:

  • Template Name: "name": "[Template Name]"

  • Template Subject: "subject": "[Template Subject]"

All other POST-able fields are optional:

  • Template Description: "description": "[Template Description]"

  • Template HTML Body: "templateDataHtml": "<html>\r\n\t<head>\r\n\t\t<title></title>\r\n\t</head>\r\n\t<body>\r\n\t\tThis is an <strong>HTML</strong> test</body>\r\n</html>\r\n"

  • Template Plain Text Body: "templateDataPlaintext": "%%DISPLAY_MSG%% click to open email in browser"

  • Advanced Options: "templateDataXml": "<encode_base64>0</encode_base64><unicode>0</unicode><encode_quoted>0</encode_quoted><utf_charset>UTF-8</utf_charset>"

  • Template Folder: "templateFolderId": 7494

Request Body Example

Using Create Template with all arguments, line breaks in JSON for readability:

curl --location 'https://mail.mydomain.com/rest/templates/' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{ "name": "Template Name",
"subject": "Template Subject",
"description": "",
"templateDataHtml": "<html>\r\n\t<head>\r\n\t\t<title></title>\r\n\t</head>\r\n\t<body>\r\n\t\tThis is an <strong>HTML</strong> test</body>\r\n</html>\r\n",
"templateDataPlaintext": "%%DISPLAY_MSG%% click to open email in browser",
"templateDataMobile": "",
"templateDataXml": "<encode_base64>0</encode_base64><unicode>0</unicode><encode_quoted>0</encode_quoted><utf_charset>UTF-8</utf_charset>",
"templateFolderId": 0
 }'


Response Body

The response returns all API available Template Properties in JSON format.  Based on the example above, the response returns:

{
    "skip": 0,
    "max": 0,
    "id": [template_id],
    "realmId": [realm_id],
    "name": "Template Name",
    "description": "",
    "subject": "Template Subject",
    "createdDate": "Mar 07, 2025 16:00:59 PM",
    "templateFolderId": 0,
    "templateDataPlaintext": "%%DISPLAY_MSG%% click to open email in browser",
    "templateDataHtml": "<html>\r\n\t<head>\r\n\t\t<title></title>\r\n\t</head>\r\n\t<body>\r\n\t\tThis is an <strong>HTML</strong> test</body>\r\n</html>\r\n",
    "templateDataMobile": "",
    "templateDataXml": "<encode_base64>0</encode_base64><unicode>0</unicode><encode_quoted>0</encode_quoted><utf_charset>UTF-8</utf_charset>",
    "createdBy": "REST API",
    "productLayoutName": "",
    "valid": true
}

Error Response

Error Response Codes include both Client Errors (4xx) and Server Errors (5xx).  Descriptions of each can be found in Response Codes