---
title: "テンプレートを更新する"
slug: "update-a-template"
abstract: "Sitecore PersonalizeテンプレートREST APIを使ってウェブテンプレートまたは意思決定テンプレートを更新する方法を説明しています。"
---
# テンプレートを更新する

PUT /v3/templates/<templateRef>

テンプレートを更新します。更新のたびにrevisionキーの値は1ずつ増。

属性

種類

概要

例

templateRef

ストリング

テンプレートの参照。  
  
テンプレート参照がわからない場合は、まず [テンプレートを取得し](https://doc.sitecore.com/personalize/ja/developers/api/rest-apis/template-rest-api/retrieve-templates.html)てください。

340ced1b-c9b7-43f0-9eec-2b9f0b7693fa

最低限、リクエスト文に以下の必要な属性を記載する必要があります:

属性

種類

概要

例

name

ストリング

テンプレートの名前です。

"Alert bar template"

friendlyId

ストリング

テンプレートのユニークなIDです。  
  
小文字の英数字文字とアンダースコアのみが許可されています。

"alert\_bar\_template\_1"

type

文字列エヌム(大文字)

テンプレートの種類。

以下のいずれかでなければなりません:  
  

-   "WEB"
-   "DECISION"
-   "CONDITION"
-   "JS\_MODULE"

status

文字列エヌム(大文字)

テンプレートの現在の状況。

以下のいずれかでなければなりません:  
  

-   "DRAFT"
-   "PUBLISHED"

description

ストリング

そのつながりの説明。

"Alert bar web template"

render

ブール値

Sitecore Personalizeアプリでウェブテンプレートのプレビューをレンダリングするかどうかを決定します。  
  
ウェブテンプレートがレンダリングできると自信がある場合にのみ、これを true に設定してください。  
  
ハンドルバーループを使うより高度なウェブテンプレートでは、これを true に設定しないでください。

true, false

defaultTemplate

ブール値

これがデフォルトのテンプレートかどうかを判断します。  
  
テンプレートを作成する際は、この値を falseに設定しなければなりません。

false

customTemplate

ブール値

これがカスタムテンプレートかどうかを判断します。  
  
テンプレートを作成する際は、この値を trueに設定しなければなりません。

true

templateElements  
  
任意

JSON JSONオブジェクトの配列

テンプレートを定義するカスタムHTML、CSS、JavaScript、FreeMarkerコード。

"mys3cr3tstr1ingforauth1!x"

オプションのオブジェクト配列templateElementsでは、テンプレート内にHTML、CSS、JavaScript、FreeMarkerのコードを組み込むことができます。 templateElementsのオブジェクトについては、以下の属性を使用します。

属性

種類

概要

例

id

文字列エナック(小文字)

template属性に含まれるコードの種類です。  
  
例えば、テンプレートにCSSコードを含めるには、この値を "css"に設定し、 template 属性でカスタムCSSコードを指定します。

以下のいずれかでなければなりません:  
  

-   "html"
-   "css"
-   "js"
-   "freemarker"

template

ストリング

ストリング化されたHTML、CSS、JavaScript、またはFreeMarkerコード。  
  
FreeMarkerコードでは、最低限開頭と閉じるカーリーブラケット {}を含める必要があります。

-   HTML: "<div id=\\"test\\">My test div</div>"
-   CSS: "#test {text-transform: uppercase}"
-   JavaScript: "insertHTMLBefore(\\"body\\");"
-   FreeMarker: "{}"

以下はtemplateElementsオブジェクト配列の例です:

"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": "{}"
 }

curl -X PUT '<baseURL>/v3/templates/340ced1b-c9b7-43f0-9eec-2b9f0b7693fa' \\
-H 'Authorization: Bearer <accessToken>' \\
-H 'Accept: application/json' \\
--data-raw '
{
 "name": "Alert bar template UPDATED",
 "friendlyId": "alert\_bar\_template\_1\_updated",
 "type": "WEB",
 "status": "DRAFT",
 "description": "Alert bar template WEB - UPDATED",
 "render": false,
 "defaultTemplate": false,
 "customTemplate": true,
 "templateElements": 
 {
 "id": "html",
 "template": "<div id=\\"test\\">My updated 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": "{}"
 }
 
}'

{
 "clientKey": "pqsPERS3lw12v5a9rrHPW1c4hET73GxQ",
 "href": "<baseURL>/v3/templates/340ced1b-c9b7-43f0-9eec-2b9f0b7693fa",
 "ref": "340ced1b-c9b7-43f0-9eec-2b9f0b7693fa",
 "name": "Alert bar template UPDATED",
 "description": "Alert bar template WEB - UPDATED",
 "modifiedByRef": "zwxCA58jwLzfeU2mNGgalCpoJzNVYOJl@clients",
 "modifiedAt": "2026-07-12T11:\`50:22\`.53994Z",
 "revision": 2,
 "archived": false,
 "friendlyId": "alert\_bar\_template\_1\_updated",
 "type": "WEB",
 "status": "DRAFT",
 "templateElements": 
 {
 "id": "html",
 "template": "<div id=\\"test\\">My updated 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": "{}"
 }
 ,
 "render": false,
 "defaultTemplate": false,
 "tags": ,
 "customTemplate": true
}