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 template code

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)

templates

JSON array of JSON objects

Custom HTML, CSS, JavaScript, and FreeMarker codes that define the template.

"mys3cr3tstr1ingforauth1!x"

templateVariables

object

Template variables and their corresponding values.

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

For the objects in the templates array of objects, use the following attributes:

Attribute

Type

Description

Example(s)

id

string enum (lowercase)

The type of code that you include in the template attribute.

For example, to include CSS code in the template, set this value to "css", then specify the custom CSS code in the template attribute.

Must be one of:

  • "html"

  • "css"

  • "js"

  • "freemarker"

template

string

Stringified HTML, CSS, JavaScript, or FreeMarker code.

For FreeMarker code, you must at a minimum include an opening and a closing curly bracket {}.

  • HTML: "<div id=\"test\">Our best [[ProductType | string]] on sale</div>"

  • CSS: "#test {text-transform: uppercase}"

  • JavaScript: "insertHTMLBefore(\"body\");"

  • FreeMarker: "{}"

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