Appearance
PUT
/communication/template-text/template-texts/{id}Required scope:
templatetext:updateOverwrites an existing template entirely. Requires the template to exist; throws template-not-found otherwise. Runs the same sanitise → render → commit algorithm as POST. The usage type (settings.channel) cannot be changed, and the content type is kept if the request leaves it out. The request does not take attachments: the attachments of the languages that stay are kept, those of a language that is removed go with it, and every active row of a language, also one of a country block that is new, gets the attachments of the language.
Request body
JSON
{
"templateCode": "order-confirmation",
"canonicalBody": "<p>{t_greeting} {customerName}</p>",
"sourceLocale": "sv",
"locales": [
"sv",
"en"
],
"translations": {
"sv": {
"t_greeting": "Hej"
}
},
"subjects": {
"sv": "Din order"
},
"senderNames": {
"sv": "Viskan"
},
"senderEmails": {
"sv": "no-reply@viskan.se"
},
"bccs": {
"sv": "archive@viskan.se"
},
"ccs": {
"sv": "sales@viskan.se"
},
"countrySettings": {
"FI": {
"senderName": "Viskan Finland",
"senderEmail": "no-reply@viskan.fi",
"cc": "",
"subjects": {
"sv": "Din order i Finland"
}
}
},
"settings": {
"name": "Order confirmation",
"channel": "email",
"editorType": "html",
"mediaEnv": "prod",
"status": "active",
"templateType": 0,
"populateSource": 500,
"contentType": "text/html",
"showInEditors": [
1099,
1056
],
"allLanguages": true
},
"prompt": "..."
}
Response
The template was updated successfully.
JSON
{
"templateCode": "order-confirmation",
"canonicalBody": "<p>{t_greeting} {customerName}</p>",
"countries": [
"FI",
"NO"
],
"sourceLocale": "sv",
"locales": [
"sv",
"en"
],
"translations": {
"sv": {
"t_greeting": "Hej"
}
},
"subjects": {
"sv": "Din order"
},
"senderNames": {
"sv": "Viskan"
},
"senderEmails": {
"sv": "no-reply@viskan.se"
},
"bccs": {
"sv": "archive@viskan.se"
},
"ccs": {
"sv": "sales@viskan.se"
},
"countrySettings": {
"FI": {
"senderName": "Viskan Finland",
"senderEmail": "no-reply@viskan.fi",
"cc": "",
"subjects": {
"sv": "Din order i Finland"
}
}
},
"settings": {
"name": "Order confirmation",
"channel": "email",
"contentType": "text/html",
"editorType": "html",
"mediaEnv": "prod",
"status": "active",
"templateType": 0,
"populateSource": 500,
"updatedAt": "2024-08-14T12:34:56.412",
"showInEditors": [
1099,
1056
],
"allLanguages": true
},
"attachments": {
}
}
| Error code | Description |
|---|---|
ambiguous-country | A country block of the body or a country of countrySettings is a country code that matches more than one country in the company's country table. |
channel-cannot-change | settings.channel names another usage type than the template has. The usage type is fixed when the template is created; create a new template to use another one. |
country-block-in-subject | A subject, also one of a country, has a country block; country blocks are only allowed in the body. |
invalid-bcc | A bcc, 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-bcc-length | A bcc, also one of a country, is longer than 60 characters. |
invalid-body-size | canonicalBody is longer than 2097152 characters. |
invalid-cc | A cc, 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-cc-length | A cc, also one of a country, is longer than 60 characters. |
invalid-channel | settings.channel must be 'email', 'sms' or 'invoicetext'. |
invalid-content-type | settings.contentType is not allowed for the usage type: an e-mail can be text/html or text/plain, an SMS only text/plain, an invoicetext text/html or text/plain. |
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-populate-source | populateSource is not one of the populate sources from the populate-sources endpoint. |
invalid-prompt-size | prompt is longer than 16384 characters. |
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-show-in-editors | showInEditors has an id that is not greater than 0, an id that is there twice, or more than 50 ids. |
invalid-source-locale | sourceLocale must be present in locales[]. |
invalid-status | settings.status must be one of 'active', 'inactive', 'draft'. |
invalid-subject | A subject, also one of a country, has a control character (such as a line break) or is longer than 500 characters. |
invalid-template-name | The template name has a control character (such as a line break) or is longer than 200 characters. |
invalid-template-type | Only templateType 0 (Normal) may be created by the editor. |
invalid-translation-size | A translation value is longer than 65536 characters. |
language-not-found | One or more requested languages are not in the supported 1:1 language↔country map. |
locale-not-found | A subject of a country is for a locale that the template does not have. |
missing-subject | An email template needs a non-blank subject for every language in locales[]; the message names the languages that have none. |
missing-translation-tokens | One or more {t_*} tokens in canonicalBody are not defined in translations[sourceLocale]. |
not-supported-for-usage-type | An invoicetext has no subject, sender name, sender e-mail, cc, bcc or country settings, and the request has a value for one of them. |
repeat-block-not-supported | An invoicetext cannot have repeat blocks ({repeat}...{/repeat}, also in the comment form), and the body or a translation has one. |
template-changed | Another request changed the template after it was read, so nothing was saved. Reload the template and try again. |
template-not-found | No template with the given code exists for the current company. |
unknown-country | A country block of the body or a country of countrySettings is not in the company's country table. |