NextSign API
Email Templates

Create an Email Template

Create an e-mail, SMS or e-Boks template with POST /api/v2/{company}/emailTemplates/create, with an example of each.

POST https://www.nextsign.dk/api/v2/{company}/emailTemplates/create

Create 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
curl --request POST 'https://www.nextsign.dk/api/v2/{company}/emailTemplates/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H '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: /api/v2/{company}/emailTemplates/6731a2b4c5d6e7f8a9b0c1d3/get. 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
curl --request POST 'https://www.nextsign.dk/api/v2/{company}/emailTemplates/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H '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: /api/v2/{company}/emailTemplates/6731a2b4c5d6e7f8a9b0c1d2/get:

{
  "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
curl --request POST 'https://www.nextsign.dk/api/v2/{company}/emailTemplates/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H '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
curl --request POST 'https://www.nextsign.dk/api/v2/{company}/emailTemplates/create' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H '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 v2 request can be at most about 4 MB, so give a bigger letter by url, or use v3, which takes up to 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.

PropertyRequiredMeaning
typeYesemail, sms or eboks
nameYes, unless copyFromThe template's name, 1–120 characters
languageNoda, en, de, se or no. Default da. The standard texts are in this language
copyFromNoThe 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 / eboksNoThe 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:

  • template is the template as Get returns it, without reading the letters' content.
  • warnings lists 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.

Pass the id as emailtemplate when you create a case, or as a recipient's template for an SMS or e-Boks template.

Errors

StatuserrorMeaning
400validation-faileddetails 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
404template-not-foundcopyFrom is not one of your templates
422template-invalidThe template would not save in the dashboard; issues lists why, each with field, code and message (below)
422letter-placeholder-issuesThe letter has {{ tag }} or { tag }; placeholderIssues shows where. Nothing was stored
400 / 422for example not-a-docx, file-too-large, invalid-base64, download-failedThe 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.