Introduction
Channels
Templates
Contacts
Messages
API
public
beta
Docs Contact Login

Sending messages

Ready to send some cool messages?

Remember there is 2 kinds of messages: transactional notifications and campaigns. Because campaigns are sent from the Notifuse UI, we will only talk about transactional notifications here.

Message format

The following example uses the API JSON format, feel free to checkout the API to integrate it easily in your project.

The API endpoint messages.send accepts an array of messages like this:


  {
    "messages": [{
      "notification": "welcome",

      "channel": "postmark-myproject",
      "channelOptions": {
        "openTracking": false
      },

      "template": "english-v1",
      "templateData": {
        "_verificationToken": "xxxxxx"
      },

      "contact": "123",
      "contactProfile": {
        "$set": {
          "firstName": "John",
          "lastName": "Doe",
          "signupAt": "2016-06-17T04:42:25.922Z"
        }
      },
      "contactCreatedAt": "2015-10-05T07:36:36.345Z",

      "sendAt": "2016-06-20T05:36:59.285Z"
    }]
  }
  

As you can see on the above example, we are sending a notification welcome with the template english-v1, to the contact 123 on the channel postmark-myproject.

We store some data in the contactProfile, set the creation date of the contact with contactCreatedAt and schedule the message to be sent in the future with sendAt.

The sendAt date cannot exceed 7 days in the future!

We also give a _verificationToken field to the templateData.

Keep in mind the templateData will be saved with the message but not stored in the contact profile!

There is also a channelOptions field in the example, that takes an object to overwrite some settings. Feel free to check the available options from the channels documentation (in a channel doc: find the Available in column, with a "message" value).

Encrypted fields & security

Some of your templateData variables are very sensitive (resert password tokens...), and should never be accessible from the Notifuse API and UI. That's why you can prepend all sensitive template data with an undescore like this: _verificationToken.

All template fields starting with an underscore are encrypted in our database and the value is stripped from the API.

This way, only channels can view the sensitive data when they receive the message.

Split routing

It can be useful to create 2 versions of the same notification to compare the open/click rates and improve your messages.

When you send a message, you can append a * at the end of your templates key, and Notifuse will randomly choose a template that starts with the provided key.

Example: you have 2 templates "english-v1" & "english-v2", you can set the template key to english*


Next: Integrate the API in your project ยป