Recipients come in several forms:

  • User - A single user
  • List - A pre-defined list of users stored with Courier
  • List pattern - A pattern that can target multiple lists of users at once
  • Audience - A Courier audience containing users.

You may also pass an array containing any combination of the above.

For ad-hoc users:

{
    "message": {
        "to": {
            "email": "darth@vader.com",
            "phone_number": "+123456789"
        }
    }
}

For ad-hoc lists:

{
    "message": {
        "to": [
            {"email": "example1@courier.com"},
            {"email": "example2@courier.com"}
        ]
    }
}

There are two styles of notification sending:

  • by template
  • ad-hoc

To send by template, first create a notification using Courier Studio, then pass the template ID in your send call. To send ad-hoc, include the content of the notification directly in the send call using Elemental.

Sending Attachments

To add an attachment, you’ll need to first retrieve it from an encoder and convert it to a base64 string. Then you’ll be able to add it to the send call using a provider override.

{
   "providers":{
      "sendgrid":{
         "override":{
            "body":{
               "subject":"Requested file - lockheed.json",
               "attachments":[
                  {
                     "content":"eyJmb28iOiJiYXIifQ==", //base64 encoded attachment
                     "type":"application/json",
                     "filename":"lockheed.json"
                  }
               ]
            },
            "config":{
               "apiKey":"<your API Key>"
            }
         }
      }
   }
}

Workspace Routing

Channel routing can be defined 3 ways:

  • At the template level
  • Inline with the request as a routing object
  • Globally as the default workspace routing

Workspace routing is the default global routing strategy that can be configured from the integrations page. This will allow users to send an inline message without the routing object present, and Courier will use your workspace routing settings to send your notification.

This object is not necessary if workspace routing is configured:

"routing": {
			"method": "single",
			"channels": [
				"email"
			]
		}

Workspace Routing

With this setting, you can send a request like so:

{
	"message": {
		"content": {
			"title": "Hello there {first_name}",
			"body": "Hello, world from {testing}"
		},
		"data": {},
		"to": {
			"email": "rodrigo@courier.com"
		}
		
	}
}