Run an Ad-hoc Automation
Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation steps. For information about what steps are available, checkout the ad hoc automation guide here.
URL: https://api.courier.com/automations/invoke
Method: POST
Body Parameters
automationobjectrequired
+ Show Properties
automationstring
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.
datajson
An object that includes any data you want to pass to a message template. The data will populate the corresponding template variables.
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.
Response
status: 200 OK
runIdstring
A unique identifier associated with the automation run.
Request Example
- cURL
- Node.js
- Ruby
- Python
- Go
- PHP
curl --request POST \
--url https://api.courier.com/automations/invoke \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"automation": {
"steps": [
{
"action": "send",
"template": "SAMPLE_TEMPLATE"
},
{
"action": "delay",
"until": "20240408T080910.123"
}
]
},
"data": {
"name": "Jane Doe",
"age": 27
},
"profile": {
"user_id": "fubar",
"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({
"automation": {
"steps": [
{
"action": "send",
"template": "SAMPLE_TEMPLATE"
},
{
"action": "delay",
"until": "20240408T080910.123"
}
]
},
"data": {
"name": "Jane Doe",
"age": 27
},
"profile": {
"user_id": "fubar",
"email": "hello@example.com"
}
})
};
fetch('https://api.courier.com/automations/invoke', 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/automations/invoke")
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 = "{\"automation\":{\"steps\":[{\"action\":\"send\",\"template\":\"SAMPLE_TEMPLATE\"},{\"action\":\"delay\",\"until\":\"20240408T080910.123\"}]},\"data\":{\"name\":\"Jane Doe\",\"age\":27},\"profile\":{\"user_id\":\"fubar\",\"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/automations/invoke"
payload = {
"automation": {
"steps": [
{
"action": "send",
"template": "SAMPLE_TEMPLATE"
},
{
"action": "delay",
"until": "20240408T080910.123"
}
]
},
"data": {
"name": "Jane Doe",
"age": 27
},
"profile": {
"user_id": "fubar",
"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/automations/invoke"
payload := strings.NewReader("{\"automation\":{\"steps\":[{\"action\":\"send\",\"template\":\"SAMPLE_TEMPLATE\"},{\"action\":\"delay\",\"until\":\"20240408T080910.123\"}]},\"data\":{\"name\":\"Jane Doe\",\"age\":27},\"profile\":{\"user_id\":\"fubar\",\"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/automations/invoke', [
'body' => '{"automation":{"steps":[{"action":"send","template":"SAMPLE_TEMPLATE"},{"action":"delay","until":"20240408T080910.123"}]},"data":{"name":"Jane Doe","age":27},"profile":{"user_id":"fubar","email":"hello@example.com"}}',
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();
Responses Example
{
"runId": "1-5e2b2615-05efbb3acab9172f88dd3f6f"
}