Skip to main content
Sitecore Documentation
  • Learn
  • Downloads
  • Changelog
  • Roadmap
PersonalizeCloud Portal
Sitecore Personalize developer documentation
  • Developing with Sitecore Personalize
    • Base URL
    • Response codes
        • Create a template
        • Retrieve templates
        • Retrieve a template
        • Update a template
        • Retrieve revisions
        • Retrieve a revision
        • Preview templates
        • Preview template code
  1. Template REST API
  1. REST APIs
  2. Template REST API
  3. 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:

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>"
      }
    ]
  }
}
 
If you have suggestions for improving this article, let us know!

Documentation Assistant

This assistant uses AI to generate responses based on Sitecore documentation. While it has access to official sources, answers may be incomplete or inaccurate and should not be considered official advice or support.
Powered by
k
kapa.ai
Protected by reCAPTCHA

© Copyright 2026, Sitecore A/S or a Sitecore affiliated company.
All rights reserved.

Privacy policySitecore Trust CenterTerms of use