Appearance
POST
/communication/template-text/template-texts/{id}/operationsRequired scope:
templatetext:updateApplies operations of the editor to content that has not been saved and returns the result, so the editor can change an e-mail by what it means (a text, a subject) instead of by its HTML. Nothing is stored: no write, no history entry, no projection. canonicalBody is required, because the element ids depend on it; every other content field is optional and a field that is left out uses the stored template, as in POST /rendered. The content is checked and cleaned exactly as a save does. The operations are applied in order to a copy, and either all are applied or the request is refused with the position of the operation and the reason. An empty list of operations returns the outline of the body. Only e-mails with HTML content have operations. The element ids are those of the sanitised body, as in a preview with withElementIds. baseRevision is required if an operation, focusId or detailIds has an element id, and must be the structureRevision of the body. The returned canonicalBody is cleaned like a save cleans it, not beautified: compare structureRevision and idMap, not strings. outline describes the elements of the body (at most about 15 kB; with focusId the part around that element in full), elements has the elements that the operations changed and those of detailIds with all attributes, results has a short summary of every operation, and findings is empty until the checker is available. Available operations: setText (key, language, value) and setSubject (language, value). remove, setStyle, setLink, setImage, setCountries and repair are refused with not-available-yet.
Request body ​
JSON
{
"canonicalBody": "<p>{t_greeting} {customerName}</p>",
"locales": [
"sv",
"en"
],
"translations": {
"sv": {
"t_greeting": "Hej"
}
},
"subjects": {
"sv": "Din order"
},
"senderNames": {
"sv": "Viskan"
},
"senderEmails": {
"sv": "no-reply@viskan.se"
},
"countrySettings": {
"FI": {
"senderName": "Viskan Finland"
}
},
"baseRevision": "3f8a0c5e",
"operations": [
{
"op": "setText",
"elementId": "e-1-0-3-2",
"elementIds": [
"e-1-0-3-2"
],
"key": "t_greeting",
"language": "sv",
"value": "Hej {customerName}"
}
],
"focusId": "e-1-0",
"detailIds": [
"e-1-0-3-2"
]
}
Response ​
The content after the operations, with the outline of the body.
JSON
{
"canonicalBody": "...",
"translations": {
"sv": {
"t_greeting": "Hej"
}
},
"subjects": {
"sv": "Din order"
},
"structureRevision": "3f8a0c5e",
"idMap": {
"e-1-2": "e-1-1"
},
"outline": {
"entries": [
{
"id": "e-1-0-3-2",
"parentId": "e-1-0",
"tag": "td",
"role": "text",
"textKeys": [
"t_greeting"
],
"text": "Hello {customerName}",
"attributes": {
"align": "center",
"bgcolor": "#ffffff"
},
"countries": {
"mode": "show",
"codes": [...]
},
"inRepeat": false,
"literalText": "Thank you!",
"preheader": false
}
],
"truncated": false
},
"elements": [
{
"id": "e-1-0-3-2",
"parentId": "e-1-0",
"tag": "td",
"role": "text",
"textKeys": [
"t_greeting"
],
"text": "Hello {customerName}",
"attributes": {
"align": "center",
"bgcolor": "#ffffff"
},
"countries": {
"mode": "show",
"codes": [
"SE"
]
},
"inRepeat": false,
"literalText": "Thank you!",
"preheader": false
}
],
"findings": [
{
"code": "not-a-full-document",
"severity": "info",
"elementId": "e-1-0",
"message": "...",
"repairable": false
}
],
"results": [
{
"index": 0,
"summary": "Set the text t_greeting for sv"
}
]
}
| Error code | Description |
|---|---|
country-block-in-subject | A subject of a country has a country block; they are only allowed in the body. A setSubject with a country block is refused as operation-refused with this code as its reason. |
element-not-found | An id of an operation, focusId or detailIds is not an element of the body; elementId is the id. |
invalid-body-size | canonicalBody is longer than 2097152 characters. |
invalid-country-settings | A key of countrySettings is blank, OTHER or a country that is there twice, or a country has no settings object. |
invalid-request | canonicalBody is null or blank, baseRevision is missing although an operation, focusId or detailIds has an element id, an operation has no op or lacks a field that it needs, or translations has a null value. |
invalid-sender-email | A sender email address, also one of a country, has a control character (such as a line break), or is not an e-mail address or a list of them separated by ';' or ',' (empty means none). |
invalid-sender-email-length | A sender email address, also one of a country, is longer than 60 characters. |
invalid-sender-name | A sender name, also one of a country, has a control character (such as a line break). |
invalid-sender-name-length | A sender name, also one of a country, is longer than 60 characters. |
invalid-subject | A subject of a country has a control character (such as a line break) or is longer than 500 characters. A setSubject with such a subject is refused as operation-refused with this code as its reason. |
invalid-translation-size | A translation value is longer than 65536 characters. |
language-not-found | A language of locales is not in the supported 1:1 language↔country map, or the language of an operation is not one of the locales of the unsaved content. |
locale-not-found | A country setting has a subject for a locale that is not one of the locales of the unsaved content. |
not-supported-for-usage-type | The request has a sender name or sender email that the usage type does not have. |
operation-refused | An operation was refused and nothing was applied. operationIndex is its position and reason is one of: unknown-operation, not-available-yet, unknown-key (the key is not used in the body or a subject), too-long (a text is longer than 65536 characters), marker-in-text (a text has a country or repeat marker), not-allowed (a text has a tag or a link that it may not have), value-changed-by-sanitiser (the cleaning would change a tag or an attribute of the text), not-stable (the body changes when it is cleaned again), invalid-subject and country-block-in-subject (a setSubject that a save would refuse with that code). |
operations-not-supported | The template is an SMS, an invoice text or an e-mail with plain-text content; operations are only for an e-mail with HTML content. |
repeat-block-not-supported | The body or a translation has a repeat block for a usage type that has none. |
structure-changed | baseRevision is not the structureRevision of the body, so the element ids are those of another structure. |
template-not-found | No template with the given code exists for the current company. |