POST /send
Custom Formatting
To improve working with cURL, Courier also supports a custom urlencoded format that can be used in the place of JSON. This format allows nested data values using square bracket syntax. This is useful when passing profile
and data
parameters. For example, a cURL --data
option with the profile
parameter and a nested email
would look like this:
--data "profile[email]=test@example.com"
Send Response Data
Sending a message is an async process. So upon submission of a message, only a messageId will be returned.
{ "messageId": "87e7c05b-4f46-fda24e356e23" }
URL: https://api.courier.com/send
Method: POST
Body Parameters
eventstringrequired
A unique identifier that can be mapped to an individual Notification. This could be the "Notification ID” on Notification detail pages (see the Notifications page in the Courier app) or a custom string mapped to the event in settings.
recipientstringrequired
A unique identifier associated with the recipient of the delivered message.
brandstring
A unique identifier that represents the brand that should be used for rendering the notification.
datajson
An object that includes any data you want to pass to a message template. The data will populate the corresponding template variables.
overridejson
An object that is merged into the request sent by Courier to the provider to override properties or to gain access to features in the provider API that are not natively supported by Courier.
preferencesjson
An object that includes any preferences for the recipient.
profilejson
An object that includes any key-value pairs required by your chosen Integrations (see our Provider Documentation for the requirements for each Integration.) If profile information is included in the request and that information already exists in the profile for the recipientId, that information will be merged.
Responses
status: 200 OK
messageIdstring
A unique identifier associated with the message sent.
status: 400 Bad Request
messagestring
A message describing the error that occurred.
typestring
[invalid_request_error] The type of error that occurred.
Request Example
- cURL
- Node.js
- Ruby
- Python
- Go
- PHP
curl --request POST \
--url https://api.courier.com/send \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"event": "EXAMPLE_NOTIFICATION",
"recipient": "8ec8c99a-c5f7-455b-9f60-8222b8a27056",
"brand": "W50NC77P524K14M5300PGPEK4JMJ",
"data": {
"name": "Jane Doe",
"age": 27
},
"profile": {
"phone_number": "2025550125",
"email": "hello@example.com"
}
}
'
// Dependencies to install:
// $ npm install node-fetch --save
const fetch = require('node-fetch');
const options = {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"event": "EXAMPLE_NOTIFICATION",
"recipient": "8ec8c99a-c5f7-455b-9f60-8222b8a27056",
"brand": "W50NC77P524K14M5300PGPEK4JMJ",
"data": {
"name": "Jane Doe",
"age": 27
},
"profile": {
"phone_number": "2025550125",
"email": "hello@example.com"
}
})
};
fetch('https://api.courier.com/send', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.courier.com/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = 'application/json'
request["Content-Type"] = 'application/json'
request.body = "{\"event\":\"EXAMPLE_NOTIFICATION\",\"recipient\":\"8ec8c99a-c5f7-455b-9f60-8222b8a27056\",\"brand\":\"W50NC77P524K14M5300PGPEK4JMJ\",\"data\":{\"name\":\"Jane Doe\",\"age\":27},\"profile\":{\"phone_number\":\"2025550125\",\"email\":\"hello@example.com\"}}"
response = http.request(request)
puts response.read_body
# Dependencies to install:
# $ python -m pip install requests
import requests
url = "https://api.courier.com/send"
payload = {
"event": "EXAMPLE_NOTIFICATION",
"recipient": "8ec8c99a-c5f7-455b-9f60-8222b8a27056",
"brand": "W50NC77P524K14M5300PGPEK4JMJ",
"data": {
"name": "Jane Doe",
"age": 27
},
"profile": {
"phone_number": "2025550125",
"email": "hello@example.com"
}
}
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.courier.com/send"
payload := strings.NewReader("{\"event\":\"EXAMPLE_NOTIFICATION\",\"recipient\":\"8ec8c99a-c5f7-455b-9f60-8222b8a27056\",\"brand\":\"W50NC77P524K14M5300PGPEK4JMJ\",\"data\":{\"name\":\"Jane Doe\",\"age\":27},\"profile\":{\"phone_number\":\"2025550125\",\"email\":\"hello@example.com\"}}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Accept", "application/json")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
<?php
// Dependencies to install:
// $ composer require guzzlehttp/guzzle
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.courier.com/send', [
'body' => '{"event":"EXAMPLE_NOTIFICATION","recipient":"8ec8c99a-c5f7-455b-9f60-8222b8a27056","brand":"W50NC77P524K14M5300PGPEK4JMJ","data":{"name":"Jane Doe","age":27},"profile":{"phone_number":"2025550125","email":"hello@example.com"}}',
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();
Responses Example
{
"messageId": "1-5e2b2615-05efbb3acab9172f88dd3f6f"
}
{
"message": "Error Message",
"type": "invalid_request_error"
}