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

Template REST API

The Template REST API enables you to perform CRUD operations on web templates and decision templates. Offers and offer templates are not available in Sitecore Personalize REST APIs.

Use the following attributes for templates:

Attribute

Type

Description

Example(s)

name

string

The name of the template.

"Alert bar template"

friendlyId

string

The unique ID of the template.

Only lowercase alphanumeric characters and underscores are allowed.

"alert_bar_template_1"

type

string enum (uppercase)

The type of the template.

Must be one of:

  • "WEB"

  • "DECISION"

  • "CONDITION"

  • "JS_MODULE"

status

string enum (uppercase)

The current status of the template.

Must be one of:

  • "DRAFT"

  • "PUBLISHED"

description

string

The description of the connection.

"Alert bar web template"

render

boolean

Determines whether to render a preview of the web template in the Sitecore Personalize app.

Only set this to true if you're confident that your web template can render.

Do not set this to true for more sophisticated web templates that use handlebars loops.

true, false

defaultTemplate

boolean

Determines whether this is a default template.

When you create a template, you must set this value to false.

false

customTemplate

boolean

Determines whether this is a custom template.

When you create a template, you must set this value to true.

true

templateElements

optional

JSON array of JSON objects

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

The codes can contain template parameters, for example, [[ProductType | string]]. Template parameters are replaced with template variable values, for example, sneakers, when the template is rendered.

N/A

archived

boolean

The archive status of the flow definition.

true, false

revisions

JSON array of JSON objects

An array of revisions of the flow definition.

N/A

revision

integer

The sequential number of the template revision.

2

The optional templateElements array of objects lets you include HTML, CSS, JavaScript, and FreeMarker codes in your templates. For the objects in templateElements, 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\">My test div</div>"

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

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

  • FreeMarker: "{}"

Here's an example of the templateElements array of objects:

RequestResponse
"templateElements": [
  {
    "id": "html",
    "template": "<div id=\"test\">My test div</div>"
  },
  {
    "id": "css",
    "template": "#test {text-transform: uppercase}"
  },
  {
    "id": "js",
    "template": "insertHTMLBefore(\"body\");\n\nconst testDiv = document.querySelector(\"#test\");\ntestDiv.insertAdjacentHTML(\"afterbegin\", \"<p>Hello from JavaScript</p>\")"
  },
  {
    "id": "freemarker",
    "template": "{}"
  }
]

Do you have some feedback for us?

If you have suggestions for improving this article,

Privacy policySitecore Trust CenterCopyright © 1999-2025 Sitecore