Update a Message Template
Change an e-mail, SMS or e-Boks template with PATCH /v3/api/message-templates/{id}. Only the fields you send change.
PATCH https://api.nextsign.dk/v3/api/message-templates/{id}Change a template. Only the fields you send change: a single text in a situation leaves every other text as it is. "" clears a text, which then sends the standard text.
Examples
A new subject for the invitation, and a text of its own for the reminder:
curl --request PATCH 'https://api.nextsign.dk/v3/api/message-templates/6731a2b4c5d6e7f8a9b0c1d3' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"email": {
"subject": "Lejekontrakt til underskrift: {case_name}",
"situations": {
"reminder": { "body": "Kære {recipient_name}\n\nVi mangler stadig din underskrift." }
}
}
}'200 OK, with the whole template. Trimmed:
{
"template": {
"id": "6731a2b4c5d6e7f8a9b0c1d3",
"name": "Lejekontrakt",
"type": "email",
"language": "da",
// the summary, see Get
"email": {
"senderName": "Land & Plan A/S",
"subject": "Lejekontrakt til underskrift: {case_name}",
"title": "Din lejekontrakt er klar",
// body, button and the other settings: unchanged
"situations": {
"reminder": {
"subject": "Husk at underskrive {case_name}",
"title": "",
"body": "Kære {recipient_name}\n\nVi mangler stadig din underskrift.",
"button": ""
}
// read, approve and allSigned: unchanged
}
}
},
"warnings": []
}Only those two texts changed. The heading, the button and the reminder's subject are as before.
An emoji in the invitation:
curl --request PATCH 'https://api.nextsign.dk/v3/api/message-templates/6731a2b4c5d6e7f8a9b0c1d2' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{ "sms": { "body": "Hej {recipient_name} 👋 Underskriv {case_name} her: {recipient_url}" } }'200 OK:
{
"template": {
"id": "6731a2b4c5d6e7f8a9b0c1d2",
"name": "Underskrift via SMS",
"title": "Underskrift via SMS",
"type": "sms",
"language": "da",
"senderName": "LandPlan",
"body": "Hej {recipient_name} 👋 Underskriv {case_name} her: {recipient_url}",
"sms": {
"senderName": "LandPlan",
"body": "Hej {recipient_name} 👋 Underskriv {case_name} her: {recipient_url}",
"allowCustomMessage": false,
"situations": {
"reminder": { "body": "Husk at underskrive {case_name}: {recipient_url}" },
"read": { "body": "" },
"approve": { "body": "" },
"allSigned": { "body": "" }
}
}
},
"warnings": [],
"sms": {
"signing": { "encoding": "UCS-2", "characters": 121, "parts": 2, "credits": 0.2 },
"read": { "encoding": "UCS-2", "characters": 121, "parts": 2, "credits": 0.2 },
"approve": { "encoding": "UCS-2", "characters": 121, "parts": 2, "credits": 0.2 },
"reminder": { "encoding": "GSM-7", "characters": 107, "parts": 1, "credits": 0.1 },
"allSigned": { "encoding": "GSM-7", "characters": 150, "parts": 1, "credits": 0.1 }
}
}The emoji is not in the GSM alphabet, so the invitation is now sent as UCS-2: at most 70 characters in one SMS, and 67 per part when it needs more. It now needs 2 parts and costs 0.2 credits per recipient. read and approve send the invitation text, so they changed too. The reminder has its own text without the emoji and is still 1 part. Try a text with preview before you save it.
Let the button work for 30 days, and give reminders their own inbox title:
curl --request PATCH 'https://api.nextsign.dk/v3/api/message-templates/6731a2b4c5d6e7f8a9b0c1d5' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"eboks": {
"buttonExpiry": "days",
"buttonExpiryDays": 30,
"situations": {
"reminder": { "enabled": true, "inboxTitle": "Husk skelforretningen {case_name}" }
}
}
}'200 OK. Trimmed:
{
"template": {
"id": "6731a2b4c5d6e7f8a9b0c1d5",
"name": "Brev om skelforretning",
"type": "eboks",
"language": "da",
// the summary, see Get
"eboks": {
"solution": "letter-with-link",
"inboxTitle": "Skelforretning {case_name}",
"button": "Se dokumenterne",
"buttonExpiry": "days",
"buttonExpiryDays": 30,
// the other settings: unchanged
"situations": {
"reminder": {
"enabled": true,
"inboxTitle": "Husk skelforretningen {case_name}",
"letter": null
}
}
}
},
"warnings": []
}enabled: true turns on the reminder's own settings. It has no letter of its own, so it sends the main letter, now titled "Husk skelforretningen Matr. 12a" instead of "Påmindelse: Skelforretning Matr. 12a".
To replace the letter, send a new one: "letter": { "url": "https://example.com/brev-om-skel-2.docx", "name": "Brev om skel.docx" }. The letter object from Get can be sent back unchanged; it is not fetched again. null removes a letter, which letter-with-link refuses, because it needs one.
Templates have no draft. A change is used from the next send of every case, preset, form and mass send that uses the template, including reminders on cases already sent. Use preview first.
Request
| Property | Meaning |
|---|---|
name | New name |
language | New language. The texts are not translated: it decides the language of the standard texts used where a text is empty |
email / sms / eboks | Settings to change, in the block of the template's type. The block of another type is refused: an SMS template takes only sms |
Give at least one field. The type cannot be changed; create a new template instead (copyFrom does not work across types either).
Response
200 OK with template, warnings and, for SMS, sms, as for create.
Errors
As for create, plus 404 template-not-found for an id that is not one of your templates. The template is checked as a whole after the change, so a change that would leave it unable to save in the dashboard is refused with 422 template-invalid. One example is switching an e-Boks template to letter-with-link while it has no letter. Nothing is stored when a request fails.
The sender address is checked only when you change it. A template keeps an address it already has.