Preview template code
POST /v3/templates/process
This endpoint lets you test template code that contains template parameters. Template parameters are dynamic placeholders that are replaced with template variable values when the template is rendered.
In the request, you include both the template parameters and the template variable values. In the response, the entire template code is returned, containing the template variable values.
At a minimum, you must provide the following required attributes in the request body:
Attribute |
Type |
Description |
Example(s) |
---|---|---|---|
|
JSON array of JSON objects |
Custom HTML, CSS, JavaScript, and FreeMarker codes that define the template. |
N/A |
|
object |
Template variables and their corresponding values. |
|
For the objects in the templates
array of objects, use the following attributes:
Attribute |
Type |
Description |
Example(s) |
---|---|---|---|
|
string enum (lowercase) |
The type of code that you include in the For example, to include CSS code in the template, set this value to |
Must be one of:
|
|
string |
Stringified HTML, CSS, JavaScript, or FreeMarker code. For FreeMarker code, you must at a minimum include an opening and a closing curly bracket |
|
In the request, you include template parameters, for example, [[ProductType | string]]
and template variable values, for example, sneakers
for ProductType
:
curl -X POST '<baseURL>/v3/templates/process' \
-H 'Authorization: Bearer <accessToken>' \
-H 'Accept: application/json' \
--data-raw '
{
"templates": [
{
"id": "html",
"template": "<title>Hi, [[Name | string]]!</title>\n<content>This week, our [[ProductType | string]] are on sale!<content>"
},
{
"id": "css",
"template": "title {text-transform: [[Style | string]]}"
}
],
"templateVariables": {
"Name": "John",
"ProductType": "sneakers",
"Style": "uppercase"
}
}'
In the response, the entire template code is returned containing the template variable values, for example, John
, sneakers
, and uppercase
:
{
"templates": [
{
"id": "html",
"template": "<title>Hi, John!</title>\n<content>This week, our sneakers are on sale!<content>"
},
{
"id": "css",
"template": "title {text-transform: uppercase}"
}
]
}