Preview templates
POST /v3/templates/renderTemplates
This endpoint lets you test templates that already exist in Sitecore Personalize.
In the request, you include the friendlyId
of one or more templates. You also include template variable values that will replace template parameters when the templates are rendered. In the response, the templates you specified in the request are returned, containing the template variable values.
At a minimum, you must provide an object called templates
in the request body. In the templates
object, you must include an object for every template that you want to test. You can choose any name for these objects, for example, object1
and object2
. Each of these objects must include the following attributes:
Attribute |
Type |
Description |
Example(s) |
---|---|---|---|
|
string |
The unique ID of the template. |
|
|
object |
Template variables and their corresponding values. |
|
In the request, you include the friendlyId
and template variable values for the templates that you want to test:
curl -X POST '<baseURL>/v3/templates/renderTemplates' \
-H 'Authorization: Bearer <accessToken>' \
-H 'Accept: application/json' \
--data-raw '
{
"templates": {
"object1": {
"friendlyId": "alert_bar_template_1",
"templateParams": {
"ProductType": "sneakers"
}
},
"object2": {
"friendlyId": "alert_bar_template_2",
"templateParams": {
"MemberCardType": "VIP"
}
}
}
}'
In the response, the entire templates are returned containing the template variable values, for example, sneakers
and VIP
:
{
"renderedTemplates": {
"object1": [
{
"id": "html",
"template": "<div>Find sneakers for men</div>"
},
{
"id": "css",
"template": "background-color: var(--page-sneakers-bg-color);"
}
],
"object2": [
{
"id": "html",
"template": "<p>As a VIP member, you get the following benefits:<p>"
}
]
}
}