Skip to main content
Users
CloudPortalLogin
  • Powered byPowered by
Developing with Sitecore Personalize
Data privacy
Before you start sending data
Integrating with Sitecore Personalize
Stream API
Personalize API Flow execution
REST APIs
  • Sitecore Personalize for developers
  • REST APIs
  • Template REST API
  • Preview templates

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)

friendlyId

string

The unique ID of the template.

"alert_bar_template_1"

templateParams

object

Template variables and their corresponding values.

{ "Name": "John", "ProductType": "sneakers" }

In the request, you include the friendlyId and template variable values for the templates that you want to test:

RequestResponse
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:

RequestResponse
{
  "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>"
      }
    ]
  }
}
 

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2026 Sitecore