Dynamic Workflow Trigger
API to dynamically create and trigger a single step workflow.
curl -X POST "https://hub.suprsend.com/{workspace_key}/dynamic-workflow/" \
--header 'Authorization: Bearer __YOUR_API_KEY__' \
--header 'Content-Type: application/json' \
--data '{
"name": "Welcome Email Workflow",
"template": "welcome-email-template",
"notification_category": "transactional",
"users": [
{
"distinct_id": "user123",
"$email": ["user@example.com"],
"$channels": ["email"]
}
],
"data": {
"user_name": "John Doe",
"welcome_message": "Welcome to our platform!"
}
}'import requests
url = "https://hub.suprsend.com/{workspace_key}/trigger/"
payload = {
"name": "_workflow_name_",
"template": "_template_slug_",
"notification_category": "transactional",
"users": [
{
"distinct_id": "_distinct_id_",
"$channels": [],
"$email": [],
"$sms": [],
"$whatsapp": [],
"$androidpush": ["<string>"],
"$iospush": ["<string>"],
"$slack": [
{
"email": "user@example.com",
"access_token": "xoxb-XXXXXXXX"
}
],
"$ms_teams": [
{
"tenant_id": "c1981ab2-9aaf-xxxx-xxxx",
"service_url": "https://smba.trafficmanager.net/amer",
"conversation_id": "19:c1524d7c-a06f-456f-8abe-xxxx"
}
]
}
],
"data": { "$attachments": [
{
"url": "https://bitcoincore.org/bitcoin.pdf",
"filename": "billing.pdf",
"ignore_if_error": True
}
] },
"delivery": {
"smart": False,
"success": "seen",
"time_to_live": "<string>",
"mandatory_channels": ["<string>"]
},
"delay": "<string>",
"trigger_at": "2023-12-25",
"tenant_id": "<string>",
"$idempotency_key": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '_workflow_name_',
template: '_template_slug_',
notification_category: 'transactional',
users: [
{
distinct_id: '_distinct_id_',
$channels: [],
$email: [],
$sms: [],
$whatsapp: [],
$androidpush: ['<string>'],
$iospush: ['<string>'],
$slack: [{email: 'user@example.com', access_token: 'xoxb-XXXXXXXX'}],
$ms_teams: [
{
tenant_id: 'c1981ab2-9aaf-xxxx-xxxx',
service_url: 'https://smba.trafficmanager.net/amer',
conversation_id: '19:c1524d7c-a06f-456f-8abe-xxxx'
}
]
}
],
data: {
$attachments: [
{
url: 'https://bitcoincore.org/bitcoin.pdf',
filename: 'billing.pdf',
ignore_if_error: true
}
]
},
delivery: {
smart: false,
success: 'seen',
time_to_live: '<string>',
mandatory_channels: ['<string>']
},
delay: '<string>',
trigger_at: '2023-12-25',
tenant_id: '<string>',
$idempotency_key: '<string>'
})
};
fetch('https://hub.suprsend.com/{workspace_key}/trigger/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://hub.suprsend.com/{workspace_key}/trigger/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '_workflow_name_',
'template' => '_template_slug_',
'notification_category' => 'transactional',
'users' => [
[
'distinct_id' => '_distinct_id_',
'$channels' => [
],
'$email' => [
],
'$sms' => [
],
'$whatsapp' => [
],
'$androidpush' => [
'<string>'
],
'$iospush' => [
'<string>'
],
'$slack' => [
[
'email' => 'user@example.com',
'access_token' => 'xoxb-XXXXXXXX'
]
],
'$ms_teams' => [
[
'tenant_id' => 'c1981ab2-9aaf-xxxx-xxxx',
'service_url' => 'https://smba.trafficmanager.net/amer',
'conversation_id' => '19:c1524d7c-a06f-456f-8abe-xxxx'
]
]
]
],
'data' => [
'$attachments' => [
[
'url' => 'https://bitcoincore.org/bitcoin.pdf',
'filename' => 'billing.pdf',
'ignore_if_error' => true
]
]
],
'delivery' => [
'smart' => false,
'success' => 'seen',
'time_to_live' => '<string>',
'mandatory_channels' => [
'<string>'
]
],
'delay' => '<string>',
'trigger_at' => '2023-12-25',
'tenant_id' => '<string>',
'$idempotency_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://hub.suprsend.com/{workspace_key}/trigger/"
payload := strings.NewReader("{\n \"name\": \"_workflow_name_\",\n \"template\": \"_template_slug_\",\n \"notification_category\": \"transactional\",\n \"users\": [\n {\n \"distinct_id\": \"_distinct_id_\",\n \"$channels\": [],\n \"$email\": [],\n \"$sms\": [],\n \"$whatsapp\": [],\n \"$androidpush\": [\n \"<string>\"\n ],\n \"$iospush\": [\n \"<string>\"\n ],\n \"$slack\": [\n {\n \"email\": \"user@example.com\",\n \"access_token\": \"xoxb-XXXXXXXX\"\n }\n ],\n \"$ms_teams\": [\n {\n \"tenant_id\": \"c1981ab2-9aaf-xxxx-xxxx\",\n \"service_url\": \"https://smba.trafficmanager.net/amer\",\n \"conversation_id\": \"19:c1524d7c-a06f-456f-8abe-xxxx\"\n }\n ]\n }\n ],\n \"data\": {\n \"$attachments\": [\n {\n \"url\": \"https://bitcoincore.org/bitcoin.pdf\",\n \"filename\": \"billing.pdf\",\n \"ignore_if_error\": true\n }\n ]\n },\n \"delivery\": {\n \"smart\": false,\n \"success\": \"seen\",\n \"time_to_live\": \"<string>\",\n \"mandatory_channels\": [\n \"<string>\"\n ]\n },\n \"delay\": \"<string>\",\n \"trigger_at\": \"2023-12-25\",\n \"tenant_id\": \"<string>\",\n \"$idempotency_key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://hub.suprsend.com/{workspace_key}/trigger/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"_workflow_name_\",\n \"template\": \"_template_slug_\",\n \"notification_category\": \"transactional\",\n \"users\": [\n {\n \"distinct_id\": \"_distinct_id_\",\n \"$channels\": [],\n \"$email\": [],\n \"$sms\": [],\n \"$whatsapp\": [],\n \"$androidpush\": [\n \"<string>\"\n ],\n \"$iospush\": [\n \"<string>\"\n ],\n \"$slack\": [\n {\n \"email\": \"user@example.com\",\n \"access_token\": \"xoxb-XXXXXXXX\"\n }\n ],\n \"$ms_teams\": [\n {\n \"tenant_id\": \"c1981ab2-9aaf-xxxx-xxxx\",\n \"service_url\": \"https://smba.trafficmanager.net/amer\",\n \"conversation_id\": \"19:c1524d7c-a06f-456f-8abe-xxxx\"\n }\n ]\n }\n ],\n \"data\": {\n \"$attachments\": [\n {\n \"url\": \"https://bitcoincore.org/bitcoin.pdf\",\n \"filename\": \"billing.pdf\",\n \"ignore_if_error\": true\n }\n ]\n },\n \"delivery\": {\n \"smart\": false,\n \"success\": \"seen\",\n \"time_to_live\": \"<string>\",\n \"mandatory_channels\": [\n \"<string>\"\n ]\n },\n \"delay\": \"<string>\",\n \"trigger_at\": \"2023-12-25\",\n \"tenant_id\": \"<string>\",\n \"$idempotency_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://hub.suprsend.com/{workspace_key}/trigger/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"_workflow_name_\",\n \"template\": \"_template_slug_\",\n \"notification_category\": \"transactional\",\n \"users\": [\n {\n \"distinct_id\": \"_distinct_id_\",\n \"$channels\": [],\n \"$email\": [],\n \"$sms\": [],\n \"$whatsapp\": [],\n \"$androidpush\": [\n \"<string>\"\n ],\n \"$iospush\": [\n \"<string>\"\n ],\n \"$slack\": [\n {\n \"email\": \"user@example.com\",\n \"access_token\": \"xoxb-XXXXXXXX\"\n }\n ],\n \"$ms_teams\": [\n {\n \"tenant_id\": \"c1981ab2-9aaf-xxxx-xxxx\",\n \"service_url\": \"https://smba.trafficmanager.net/amer\",\n \"conversation_id\": \"19:c1524d7c-a06f-456f-8abe-xxxx\"\n }\n ]\n }\n ],\n \"data\": {\n \"$attachments\": [\n {\n \"url\": \"https://bitcoincore.org/bitcoin.pdf\",\n \"filename\": \"billing.pdf\",\n \"ignore_if_error\": true\n }\n ]\n },\n \"delivery\": {\n \"smart\": false,\n \"success\": \"seen\",\n \"time_to_live\": \"<string>\",\n \"mandatory_channels\": [\n \"<string>\"\n ]\n },\n \"delay\": \"<string>\",\n \"trigger_at\": \"2023-12-25\",\n \"tenant_id\": \"<string>\",\n \"$idempotency_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body"Accepted - OK"{
"status": "fail",
"message": "BAD REQUEST"
}Authorizations
Pass as Bearer <API_KEY>. Get API Key from SuprSend dashboard Developers -> API Keys section.
Path Parameters
Body
Unique name of the workflow. The workflow name should be easily identifiable for your reference at a later stage. You can see workflow-related analytics on the workflow page (how many notifications were sent, delivered, clicked or interacted).
Unique slug of the template created on SuprSend dashboard. You can get this by clicking on the clipboard icon next to the Template name on SuprSend templates page.
Used to apply user category level preferences [blocked] on notification trigger.
Array object of target users.
Show child attributes
Show child attributes
variable data required to render dynamic template content or workflow properties like dynamic delay or channel override in send node.
Show child attributes
Show child attributes
delivery instructions for the workflow. You can set Smart Delivery preference by setting "smart":true
Show child attributes
Show child attributes
Workflow will be halted for the time mentioned in delay, and become active once the delay period is over. Format - XXdXXhXXmXXs or if its number (n) then delay is in seconds (n)
Trigger workflow on a specific date-time. Format - date string in ISO 8601 e.g. "2022-08-27T20:14:51.643Z"
string identifier of the tenant this workflow is associated with
Unique identifier of the request (deduplicates request for 24hrs)
Response
202
The response is of type string.
"Accepted - OK"
Was this page helpful?
curl -X POST "https://hub.suprsend.com/{workspace_key}/dynamic-workflow/" \
--header 'Authorization: Bearer __YOUR_API_KEY__' \
--header 'Content-Type: application/json' \
--data '{
"name": "Welcome Email Workflow",
"template": "welcome-email-template",
"notification_category": "transactional",
"users": [
{
"distinct_id": "user123",
"$email": ["user@example.com"],
"$channels": ["email"]
}
],
"data": {
"user_name": "John Doe",
"welcome_message": "Welcome to our platform!"
}
}'import requests
url = "https://hub.suprsend.com/{workspace_key}/trigger/"
payload = {
"name": "_workflow_name_",
"template": "_template_slug_",
"notification_category": "transactional",
"users": [
{
"distinct_id": "_distinct_id_",
"$channels": [],
"$email": [],
"$sms": [],
"$whatsapp": [],
"$androidpush": ["<string>"],
"$iospush": ["<string>"],
"$slack": [
{
"email": "user@example.com",
"access_token": "xoxb-XXXXXXXX"
}
],
"$ms_teams": [
{
"tenant_id": "c1981ab2-9aaf-xxxx-xxxx",
"service_url": "https://smba.trafficmanager.net/amer",
"conversation_id": "19:c1524d7c-a06f-456f-8abe-xxxx"
}
]
}
],
"data": { "$attachments": [
{
"url": "https://bitcoincore.org/bitcoin.pdf",
"filename": "billing.pdf",
"ignore_if_error": True
}
] },
"delivery": {
"smart": False,
"success": "seen",
"time_to_live": "<string>",
"mandatory_channels": ["<string>"]
},
"delay": "<string>",
"trigger_at": "2023-12-25",
"tenant_id": "<string>",
"$idempotency_key": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '_workflow_name_',
template: '_template_slug_',
notification_category: 'transactional',
users: [
{
distinct_id: '_distinct_id_',
$channels: [],
$email: [],
$sms: [],
$whatsapp: [],
$androidpush: ['<string>'],
$iospush: ['<string>'],
$slack: [{email: 'user@example.com', access_token: 'xoxb-XXXXXXXX'}],
$ms_teams: [
{
tenant_id: 'c1981ab2-9aaf-xxxx-xxxx',
service_url: 'https://smba.trafficmanager.net/amer',
conversation_id: '19:c1524d7c-a06f-456f-8abe-xxxx'
}
]
}
],
data: {
$attachments: [
{
url: 'https://bitcoincore.org/bitcoin.pdf',
filename: 'billing.pdf',
ignore_if_error: true
}
]
},
delivery: {
smart: false,
success: 'seen',
time_to_live: '<string>',
mandatory_channels: ['<string>']
},
delay: '<string>',
trigger_at: '2023-12-25',
tenant_id: '<string>',
$idempotency_key: '<string>'
})
};
fetch('https://hub.suprsend.com/{workspace_key}/trigger/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://hub.suprsend.com/{workspace_key}/trigger/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '_workflow_name_',
'template' => '_template_slug_',
'notification_category' => 'transactional',
'users' => [
[
'distinct_id' => '_distinct_id_',
'$channels' => [
],
'$email' => [
],
'$sms' => [
],
'$whatsapp' => [
],
'$androidpush' => [
'<string>'
],
'$iospush' => [
'<string>'
],
'$slack' => [
[
'email' => 'user@example.com',
'access_token' => 'xoxb-XXXXXXXX'
]
],
'$ms_teams' => [
[
'tenant_id' => 'c1981ab2-9aaf-xxxx-xxxx',
'service_url' => 'https://smba.trafficmanager.net/amer',
'conversation_id' => '19:c1524d7c-a06f-456f-8abe-xxxx'
]
]
]
],
'data' => [
'$attachments' => [
[
'url' => 'https://bitcoincore.org/bitcoin.pdf',
'filename' => 'billing.pdf',
'ignore_if_error' => true
]
]
],
'delivery' => [
'smart' => false,
'success' => 'seen',
'time_to_live' => '<string>',
'mandatory_channels' => [
'<string>'
]
],
'delay' => '<string>',
'trigger_at' => '2023-12-25',
'tenant_id' => '<string>',
'$idempotency_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://hub.suprsend.com/{workspace_key}/trigger/"
payload := strings.NewReader("{\n \"name\": \"_workflow_name_\",\n \"template\": \"_template_slug_\",\n \"notification_category\": \"transactional\",\n \"users\": [\n {\n \"distinct_id\": \"_distinct_id_\",\n \"$channels\": [],\n \"$email\": [],\n \"$sms\": [],\n \"$whatsapp\": [],\n \"$androidpush\": [\n \"<string>\"\n ],\n \"$iospush\": [\n \"<string>\"\n ],\n \"$slack\": [\n {\n \"email\": \"user@example.com\",\n \"access_token\": \"xoxb-XXXXXXXX\"\n }\n ],\n \"$ms_teams\": [\n {\n \"tenant_id\": \"c1981ab2-9aaf-xxxx-xxxx\",\n \"service_url\": \"https://smba.trafficmanager.net/amer\",\n \"conversation_id\": \"19:c1524d7c-a06f-456f-8abe-xxxx\"\n }\n ]\n }\n ],\n \"data\": {\n \"$attachments\": [\n {\n \"url\": \"https://bitcoincore.org/bitcoin.pdf\",\n \"filename\": \"billing.pdf\",\n \"ignore_if_error\": true\n }\n ]\n },\n \"delivery\": {\n \"smart\": false,\n \"success\": \"seen\",\n \"time_to_live\": \"<string>\",\n \"mandatory_channels\": [\n \"<string>\"\n ]\n },\n \"delay\": \"<string>\",\n \"trigger_at\": \"2023-12-25\",\n \"tenant_id\": \"<string>\",\n \"$idempotency_key\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://hub.suprsend.com/{workspace_key}/trigger/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"_workflow_name_\",\n \"template\": \"_template_slug_\",\n \"notification_category\": \"transactional\",\n \"users\": [\n {\n \"distinct_id\": \"_distinct_id_\",\n \"$channels\": [],\n \"$email\": [],\n \"$sms\": [],\n \"$whatsapp\": [],\n \"$androidpush\": [\n \"<string>\"\n ],\n \"$iospush\": [\n \"<string>\"\n ],\n \"$slack\": [\n {\n \"email\": \"user@example.com\",\n \"access_token\": \"xoxb-XXXXXXXX\"\n }\n ],\n \"$ms_teams\": [\n {\n \"tenant_id\": \"c1981ab2-9aaf-xxxx-xxxx\",\n \"service_url\": \"https://smba.trafficmanager.net/amer\",\n \"conversation_id\": \"19:c1524d7c-a06f-456f-8abe-xxxx\"\n }\n ]\n }\n ],\n \"data\": {\n \"$attachments\": [\n {\n \"url\": \"https://bitcoincore.org/bitcoin.pdf\",\n \"filename\": \"billing.pdf\",\n \"ignore_if_error\": true\n }\n ]\n },\n \"delivery\": {\n \"smart\": false,\n \"success\": \"seen\",\n \"time_to_live\": \"<string>\",\n \"mandatory_channels\": [\n \"<string>\"\n ]\n },\n \"delay\": \"<string>\",\n \"trigger_at\": \"2023-12-25\",\n \"tenant_id\": \"<string>\",\n \"$idempotency_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://hub.suprsend.com/{workspace_key}/trigger/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"_workflow_name_\",\n \"template\": \"_template_slug_\",\n \"notification_category\": \"transactional\",\n \"users\": [\n {\n \"distinct_id\": \"_distinct_id_\",\n \"$channels\": [],\n \"$email\": [],\n \"$sms\": [],\n \"$whatsapp\": [],\n \"$androidpush\": [\n \"<string>\"\n ],\n \"$iospush\": [\n \"<string>\"\n ],\n \"$slack\": [\n {\n \"email\": \"user@example.com\",\n \"access_token\": \"xoxb-XXXXXXXX\"\n }\n ],\n \"$ms_teams\": [\n {\n \"tenant_id\": \"c1981ab2-9aaf-xxxx-xxxx\",\n \"service_url\": \"https://smba.trafficmanager.net/amer\",\n \"conversation_id\": \"19:c1524d7c-a06f-456f-8abe-xxxx\"\n }\n ]\n }\n ],\n \"data\": {\n \"$attachments\": [\n {\n \"url\": \"https://bitcoincore.org/bitcoin.pdf\",\n \"filename\": \"billing.pdf\",\n \"ignore_if_error\": true\n }\n ]\n },\n \"delivery\": {\n \"smart\": false,\n \"success\": \"seen\",\n \"time_to_live\": \"<string>\",\n \"mandatory_channels\": [\n \"<string>\"\n ]\n },\n \"delay\": \"<string>\",\n \"trigger_at\": \"2023-12-25\",\n \"tenant_id\": \"<string>\",\n \"$idempotency_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body"Accepted - OK"{
"status": "fail",
"message": "BAD REQUEST"
}