Appearance
POST
/communication/template-text/template-textsRequired scope:
templatetext:createCreates a new logical template. Sanitises the canonical body as e-mail HTML (only if the content type is text/html), renders the bodies per language and per country named by the country blocks or the country settings, persists all sidecar rows, and regenerates the legacy notificationtemplate projection — all in a single transaction. Rejects the request if the templateCode already exists in either the sidecar or the legacy notificationtemplate table, or if a country block or a country setting names a country that Ramos does not know.
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 created 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. |
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-request | templateCode is null or blank. |
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-code | templateCode does not start with a letter or a digit, or has a character other than a letter, a digit, an underscore or a hyphen. |
invalid-template-code-length | templateCode is longer than 30 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-code-already-exists | A template with the given code already exists in either the sidecar or the legacy notificationtemplate table. |
unknown-country | A country block of the body or a country of countrySettings is not in the company's country table. |