Create a Message Template
Create an e-mail, SMS or e-Boks template with POST /v3/api/message-templates, with an example of each.
POST https://api.nextsign.dk/v3/api/message-templatesCreate a template for your company. Give type, name and the settings block of that type. Everything you leave out gets the same starting point as a template made in the dashboard, so a few fields are enough. Message Templates describes every setting.
Examples
An invitation to sign a rental agreement, with its own subject, heading, text and button colour, and its own subject for the reminder and for the e-mail when everyone has signed. The other texts are NextSign's standard texts.
curl --request POST 'https://api.nextsign.dk/v3/api/message-templates' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"type": "email",
"name": "Lejekontrakt",
"language": "da",
"email": {
"senderName": "Land & Plan A/S",
"subject": "Underskriv {case_name}",
"title": "Din lejekontrakt er klar",
"body": "Kære {recipient_name}\n\nHer er lejekontrakten til underskrift. Læs den igennem, og underskriv med MitID.",
"button": "Læs og underskriv",
"design": { "accentColor": "#0f5132", "textColor": "#ffffff" },
"situations": {
"reminder": { "subject": "Husk at underskrive {case_name}" },
"allSigned": { "subject": "Lejekontrakten er underskrevet" }
}
}
}'201 Created, with Location: /v3/api/message-templates/6731a2b4c5d6e7f8a9b0c1d3. The answer has the whole template, as Get returns it. Trimmed here:
{
"template": {
"id": "6731a2b4c5d6e7f8a9b0c1d3",
"name": "Lejekontrakt",
"title": "Din lejekontrakt er klar",
"type": "email",
"language": "da",
// subject, senderName, sentFrom, body, button, situations: a short summary, see Get
"email": {
"senderName": "Land & Plan A/S",
"senderEmail": "noreply@nextsign.dk",
"subject": "Underskriv {case_name}",
"title": "Din lejekontrakt er klar",
"body": "Kære {recipient_name}\n\nHer er lejekontrakten til underskrift. Læs den igennem, og underskriv med MitID.",
"button": "Læs og underskriv",
"warning": "Del ikke linket med nogen, da det indeholder krypterede persondata.",
"showWarning": true,
// signingMessage, linkHelp, footer and allowCustomMessage: as Get shows them
"design": { "accentColor": "#0f5132", "textColor": "#ffffff", "buttonFullWidth": false },
"situations": {
"reminder": {
"subject": "Husk at underskrive {case_name}",
"title": "",
"body": "",
"button": ""
},
"allSigned": {
"subject": "Lejekontrakten er underskrevet",
"title": "",
"body": "",
"button": ""
}
// read and approve: as Get shows them
}
}
},
"warnings": []
}The e-mail is sent from noreply@nextsign.dk unless you give senderEmail: an address on your company's own verified e-mail domain, or the one your partner lends you. senderName is the name the recipient sees.
An SMS sent from "LandPlan", with its own text for the invitation and for the reminder:
curl --request POST 'https://api.nextsign.dk/v3/api/message-templates' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"type": "sms",
"name": "Underskrift via SMS",
"sms": {
"senderName": "LandPlan",
"body": "Hej {recipient_name}, underskriv {case_name} her: {recipient_url}",
"situations": { "reminder": { "body": "Husk at underskrive {case_name}: {recipient_url}" } }
}
}'201 Created, with Location: /v3/api/message-templates/6731a2b4c5d6e7f8a9b0c1d2:
{
"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": "GSM-7", "characters": 119, "parts": 1, "credits": 0.1 },
"read": { "encoding": "GSM-7", "characters": 119, "parts": 1, "credits": 0.1 },
"approve": { "encoding": "GSM-7", "characters": 119, "parts": 1, "credits": 0.1 },
"reminder": { "encoding": "GSM-7", "characters": 107, "parts": 1, "credits": 0.1 },
"allSigned": { "encoding": "GSM-7", "characters": 150, "parts": 1, "credits": 0.1 }
}
}sms in the answer is each SMS as it will be sent, with example values. The link and the line "Denne besked kan ikke besvares." are counted. All five fit in one SMS and cost 0.1 credits each. read and approve have no text of their own, so they send the invitation text. Characters, parts and cost explains the count.
senderName is the sender the phone shows: 1 to 11 letters or digits, with no spaces.
The documents directly. The recipient gets the case's documents in e-Boks, with a button to the signing page:
curl --request POST 'https://api.nextsign.dk/v3/api/message-templates' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"type": "eboks",
"name": "Dokumenter i e-Boks",
"eboks": {
"solution": "documents-directly",
"inboxTitle": "Underskriv {case_name}",
"button": "Se og underskriv"
}
}'201 Created. Trimmed:
{
"template": {
"id": "6731a2b4c5d6e7f8a9b0c1d4",
"name": "Dokumenter i e-Boks",
"title": "Underskriv {case_name}",
"type": "eboks",
"language": "da",
// solution, letters, inboxTitle, button, hideButton: a short summary, see Get
"eboks": {
"solution": "documents-directly",
"inboxTitle": "Underskriv {case_name}",
"button": "Se og underskriv",
"hideButton": false,
"buttonExpiry": "case",
"addressBlock": false,
"readReceipt": "none",
"letterFallback": false,
"letter": null
// markCompleteOnSend, allowCustomMessage, message and situations: as Get shows them
}
},
"warnings": []
}Your own letter, with a button. With letter-with-link the recipient gets your Word letter, with a button to the documents. letterFallback sends the letter on paper to a recipient who has no e-Boks.
curl --request POST 'https://api.nextsign.dk/v3/api/message-templates' \
--header "Authorization: Bearer $NEXTSIGN_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"type": "eboks",
"name": "Brev om skelforretning",
"eboks": {
"solution": "letter-with-link",
"inboxTitle": "Skelforretning {case_name}",
"button": "Se dokumenterne",
"letterFallback": true,
"letter": { "url": "https://example.com/brev-om-skel.docx", "name": "Brev om skel.docx" }
}
}'The letter is fetched and checked before anything is saved. Write its fields as {recipient_name}: one brace on each side and no spaces. A letter with {{ tag }} is refused with 422 letter-placeholder-issues. Instead of a url, you can send the file itself: "letter": { "base64": "UEsDBBQABgAI…", "name": "Brev om skel.docx" }. A letter can be at most 15 MB.
201 Created. The letter is stored with the template, and its url is now NextSign's copy. Trimmed:
{
"template": {
"id": "6731a2b4c5d6e7f8a9b0c1d5",
"name": "Brev om skelforretning",
"title": "Skelforretning {case_name}",
"type": "eboks",
"language": "da",
"solution": "letter-with-link",
"letters": [
{
"letter": "main",
"name": "Brev om skel.docx",
"format": "docx",
"url": "https://nextsign.hel1.your-objectstorage.com/655e252f708ff057141e577e/letter/de6e3a9385d0f017-Brev_om_skel.docx",
"usedFor": "the signing send, and every situation without its own letter",
"usedOnSend": true
}
],
// inboxTitle, button, hideButton: a short summary, see Get
"eboks": {
"solution": "letter-with-link",
"inboxTitle": "Skelforretning {case_name}",
"button": "Se dokumenterne",
"hideButton": false,
"buttonExpiry": "case",
"letterFallback": true,
"letter": {
"name": "Brev om skel.docx",
"format": "docx",
"url": "https://nextsign.hel1.your-objectstorage.com/655e252f708ff057141e577e/letter/de6e3a9385d0f017-Brev_om_skel.docx"
}
// the other settings: as Get shows them
}
},
"warnings": []
}The third solution, letterhead-with-documents, sends your letter as the front page, followed by the documents.
Request
Unknown properties are rejected with 400 validation-failed.
| Property | Required | Meaning |
|---|---|---|
type | Yes | email, sms or eboks |
name | Yes, unless copyFrom | The template's name, 1–120 characters |
language | No | da, en, de, se or no. Default da. The standard texts are in this language |
copyFrom | No | The id of one of your templates of the same type. The new template starts as a copy of it, including its texts, letters and design, and then gets the fields you give. Without name it is named after the original, followed by " (Kopi)" |
email / sms / eboks | No | The settings block. Only the block of type is accepted |
A copy of the e-mail template above, with another name and subject:
{
"type": "email",
"copyFrom": "6731a2b4c5d6e7f8a9b0c1d3",
"name": "Erhvervslejekontrakt",
"email": { "subject": "Underskriv erhvervslejekontrakten {case_name}" }
}Response
201 Created, with Location pointing to the new template:
templateis the template as Get returns it, without reading the letters' content.warningslists placeholders that will not be filled and e-mail HTML that is not kept (warnings). Nothing is refused because of them.sms(SMS templates only) is the length and cost of each SMS as sent, with example values. Preview shows the texts and takes your own values.
Use the id as messageTemplateId when you create a case: on the case for an e-mail template, on the recipient for an SMS or e-Boks template.
Errors
| Status | error | Meaning |
|---|---|---|
| 400 | validation-failed | details names each field: an unknown field, the block of another type, an SMS sender over 11 characters or with a space, a text too long |
| 404 | template-not-found | copyFrom is not one of your templates |
| 422 | template-invalid | The template would not save in the dashboard; issues lists why, each with field, code and message (below) |
| 422 | letter-placeholder-issues | The letter has {{ tag }} or { tag }; placeholderIssues shows where. Nothing was stored |
| 400 / 422 | for example not-a-docx, file-too-large, invalid-base64, download-failed | The letter could not be read or is not a Word file; field says which letter |
issues codes: invalid-sender-domain (an email.senderEmail your company may not send from), inbox-title-missing, inbox-title-too-short, button-missing, button-too-short, button-too-long, letter-missing (the solution needs a letter), button-expiry-days-missing, cover-letter-missing (allSigned with source: "letter" needs its own letter).
Nothing is stored when a request fails.