Use the send API to send a message to one or more recipients.
Base URL: https://api.courier.com
Path: /send
Method: POST
{
"message": {
"to": {
"email": "darth@vader.com"
},
"content": {
"title": "Why did Anakin cross the road??",
"body": "To get to the dark side."
}
}
}
Request Body
The POST
accepts a JSON payload with a single message property.
Defines the message to be delivered
+ Show message object
The message
property has the following primary top-level properties. They define the destination and content of the message.
Additional advanced configuration fields are defined below.
The recipient or a list of recipients of the message
+ Show profile object
The id of the notification template to be rendered and sent to the recipient(s). This field or the content field must be supplied.
Describes the content of the message in a way that will work for email, push, chat, or any channel. Either this or template must be specified.
+ Show content object
An arbitrary object that includes any data you want to pass to the message. The data will populate the corresponding template or elements variables.
Required. The recipient or recipients or this message.
Example of sending to a single recipient:
"to": {
"email": "darth@vader.com"
}
Example of sending to multiple recipients:
"to": [
{
"email": "darth@vader.com"
},
{
"email": "luke@skywalker.com"
}
]
The user's preferred ISO 639-1 language code.
Additional provider specific fields may be specified.
Id of a user stored with Courier.
A unique identifier associated with a List of subscribers. A message will be sent to each subscriber in the list.
A unique identifier associated with an Audience. A message will be sent to each user in the audience.
A unique identifier associated with an Tenant. A message will be sent to each member of the tenant using any branding or default preferences associated with that tenant.
An object that includes any data you want to pass to the message. The data will populate the corresponding template or content variables.
Context to load with this recipient. Will override any context set on
message.context
.
+ Show context
When sending to a list or audience, this field may be supplied for adhoc filtering criteria. When a member of the list or audience doesn't meet the criteria of each supplied filter, they will be skipped. A list of available operators is available under
audience operators.
Note: This feature is part of the Tenants Private Beta.
The Content Property
Describes the content of the message in a way that will work for email, push, chat, or any channel. Either this field or template must be specified.
"content": {
"title": "Why did Anakin cross the road?",
"body": "To get to the dark side!"
}
The title to be displayed by channels that support a title, such as email.
Text content displayed in the notification. Supports markdown.
Elements describing the content of the notification. Use this field or body. See
elements for a list of available elements.
The version of elemental being supplied. Currently, only `2020-01-01` is supported.
An arbitrary object that includes any data you want to pass to the message. The data can be used to populate corresponding template/content variables or be passed-through to your application via the Courier client SDKs.
"data": {
"real_name": "Anakin Skywalker",
"nickname": "Darth Vader",
"category": "villain"
}
The following properties support overriding configured values and defaults at run-time and attaching metadata to messages.
Id of the brand that should be used for rendering the message. If not specified, the brand configured as default brand will be used.
Define run-time configuration for one or more channels
. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId
's are: email
, sms
, push
, inbox
, direct_message
, banner
, and webhook
.+ Show channel config object
Context information such as tenant_id to send the notification with.
+ Show context config object
Defines the time to wait before delivering the message.
+ Show delay object
Metadata such as utm tracking attached with the notification.
+ Show metadata object
Expiry allows you to set an absolute or relative time in which a message expires. Note: This is only valid for the Courier Inbox channel as of 12-08-2022.
+ Show expiry object
Configuration related to this notification and user preferences. Primary used to set the subscription_topic associated with this message
+ Show preferences object
The providers object is a map of valid provider identifiers (e.g. twilio, slack, etc.) to provider configuration objects. If you don't specify providers, Courier will use the default configuration for each provider.
+ Show provider config object
Allows you to customize which channel(s) Courier will potentially deliver the message. If no routing key is specified, Courier will use the default routing configuration or routing defined by the template.
+ Show routing object
In the event of a retryable error, this field defines the amount of time courier should attempt to deliver the message and/or failover to another provider or channel
+ Show timeout object
An object whose keys are valid channel identifiers (email, sms, etc) which map to an object with the following properties.
"channels": {
"sms": {
"brand_id": "xxx"
}
}
Specify the ID of the Brand which will apply to all messages sent through this channel.
A JavaScript conditional expression to determine if the message should be sent through the channel. Has access to the data
and profile
object. Ex. `data.name === profile.name`
A list of providers enabled for this channel. Courier will select one provider to send through unless routing_method
is set to all.
The method for selecting the providers to send the message with. Valid values are single
or all
. Single will send to one of the available providers for this channel, all will send the message through all channels. Defaults to single
.
Channel specific overrides.
Metadata such as utm tracking attached with the notification through this channel.
+ Show metadata object
Time in ms to attempt the channel before failing over to the next available channel.Business Tier
Expiry allows you to set an absolute or relative time in which a message expires.
Note: This is only valid for the Courier Inbox channel as of 12-08-2022.
An epoch timestamp or ISO8601 timestamp with timezone (YYYY-MM-DDThh:mm:ss.sTZD) that describes the time in which a message expires.
A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H).
Attach information not related to the content of the message for application or marketing use cases.
An arbitrary string to tracks the event that generated this request (e.g. 'signup').
An array of up to 9 tags you wish to associate with this request (and corresponding messages) for later analysis. Individual tags cannot be more than 30 characters in length.
A unique ID used to correlate this request to processing on your servers. Note: Courier does not verify the uniqueness of this ID.
Identify the campaign that refers traffic to a specific website, and attributes the browser's website session.
+ Show utm fields
An object whose keys are valid provider identifiers which map to an object with the following properties:
"providers": {
"slack": {
"if": "profile.locale === 'en-us'"
}
}
A JavaScript conditional expression to determine if the message should be sent through the channel. Has access to the data
and profile
object. Ex. `data.name === profile.name`
Provider specific overrides.
Metadata such as utm tracking attached with the notification through this provider.
Time in ms to attempt the provider before failing over to the next available channel.Business Tier
Allows you to customize which channel(s) Courier will potentially deliver the message. If no
routing key is specified, Courier will use the default routing configuration or routing
defined by the template.
A list of channels or providers to send the message through. Can also recursively define sub-routing methods, which can be useful for defining advanced push notification delivery strategies.
The simplest option is to specify an array of strings that match the Channel identifies you want to use to send the message.
In this example, courier will send to one of sms, email or inbox depending of user preferences.
"routing": {
"method": "single",
"channels": ["sms", "email", "inbox"]
}
The routing property can be used to define advanced routing scenarios. In this example, we send a
push notification to both the user's Apple and Android devices. If sending via push fails, we
send an sms instead.
"routing": {
"method": "single",
"channels": [
{
"method": "all",
"channels": ["apn", "firebase-fcm"]
},
"sms"
]
}
Note: Automated failover is a business tier feature.