---
title: "Preview template code"
slug: "preview-template-code"
abstract: "Describes how to preview template code that contains variables using the Sitecore Personalize Template REST API."
---
# Preview template code

`POST /v3/templates/process`

This endpoint lets you test [template code](https://doc.sitecore.com/personalize/en/developers/api/rest-apis/template-rest-api.html#UUID-0cc970c9-58f1-b122-47be-937a878685ee_UUID-e931be17-ea97-da26-bc4d-955753ffa2da) 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.<br><br>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:<br><br><ul><li>`"html"`</li><li>`"css"`</li><li>`"js"`</li><li>`"freemarker"`</li></ul> |
| `template` | string | Stringified HTML, CSS, JavaScript, or FreeMarker code.<br><br>For FreeMarker code, you must at a minimum include an opening and a closing curly bracket `{}`. | <ul><li>HTML: `"<div id=\"test\">Our best [[ProductType \| string]] on sale</div>"`</li><li>CSS: `"#test {text-transform: uppercase}"`</li><li>JavaScript: `"insertHTMLBefore(\"body\");"`</li><li>FreeMarker: `"{}"`</li></ul> |

In the request, you include template parameters, for example, `[[ProductType | string]]` and template variable values, for example, `sneakers` for `ProductType`:

```curl
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`:

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

```