Trigger a campaign
curl --request POST \
--url https://api.clix.so/api/v1/campaigns/{campaign_id}:trigger \
--header 'Content-Type: application/json' \
--header 'X-Clix-API-Key: <api-key>' \
--header 'X-Clix-Project-ID: <api-key>' \
--data '
{
"audience": {
"broadcast": true,
"targets": [
{
"project_user_id": "<string>",
"device_id": "<string>"
}
]
},
"properties": {}
}
'import requests
url = "https://api.clix.so/api/v1/campaigns/{campaign_id}:trigger"
payload = {
"audience": {
"broadcast": True,
"targets": [
{
"project_user_id": "<string>",
"device_id": "<string>"
}
]
},
"properties": {}
}
headers = {
"X-Clix-Project-ID": "<api-key>",
"X-Clix-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Clix-Project-ID': '<api-key>',
'X-Clix-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
audience: {
broadcast: true,
targets: [{project_user_id: '<string>', device_id: '<string>'}]
},
properties: {}
})
};
fetch('https://api.clix.so/api/v1/campaigns/{campaign_id}: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://api.clix.so/api/v1/campaigns/{campaign_id}: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([
'audience' => [
'broadcast' => true,
'targets' => [
[
'project_user_id' => '<string>',
'device_id' => '<string>'
]
]
],
'properties' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Clix-API-Key: <api-key>",
"X-Clix-Project-ID: <api-key>"
],
]);
$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://api.clix.so/api/v1/campaigns/{campaign_id}:trigger"
payload := strings.NewReader("{\n \"audience\": {\n \"broadcast\": true,\n \"targets\": [\n {\n \"project_user_id\": \"<string>\",\n \"device_id\": \"<string>\"\n }\n ]\n },\n \"properties\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Clix-Project-ID", "<api-key>")
req.Header.Add("X-Clix-API-Key", "<api-key>")
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://api.clix.so/api/v1/campaigns/{campaign_id}:trigger")
.header("X-Clix-Project-ID", "<api-key>")
.header("X-Clix-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audience\": {\n \"broadcast\": true,\n \"targets\": [\n {\n \"project_user_id\": \"<string>\",\n \"device_id\": \"<string>\"\n }\n ]\n },\n \"properties\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.clix.so/api/v1/campaigns/{campaign_id}:trigger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Clix-Project-ID"] = '<api-key>'
request["X-Clix-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"audience\": {\n \"broadcast\": true,\n \"targets\": [\n {\n \"project_user_id\": \"<string>\",\n \"device_id\": \"<string>\"\n }\n ]\n },\n \"properties\": {}\n}"
response = http.request(request)
puts response.read_body{
"trigger_id": "<string>"
}"Campaign Id must be provided"Campaigns
Trigger Campaign
Triggers an API-triggered campaign to send messages to a specific audience
POST
/
api
/
v1
/
campaigns
/
{campaign_id}
:trigger
Trigger a campaign
curl --request POST \
--url https://api.clix.so/api/v1/campaigns/{campaign_id}:trigger \
--header 'Content-Type: application/json' \
--header 'X-Clix-API-Key: <api-key>' \
--header 'X-Clix-Project-ID: <api-key>' \
--data '
{
"audience": {
"broadcast": true,
"targets": [
{
"project_user_id": "<string>",
"device_id": "<string>"
}
]
},
"properties": {}
}
'import requests
url = "https://api.clix.so/api/v1/campaigns/{campaign_id}:trigger"
payload = {
"audience": {
"broadcast": True,
"targets": [
{
"project_user_id": "<string>",
"device_id": "<string>"
}
]
},
"properties": {}
}
headers = {
"X-Clix-Project-ID": "<api-key>",
"X-Clix-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Clix-Project-ID': '<api-key>',
'X-Clix-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
audience: {
broadcast: true,
targets: [{project_user_id: '<string>', device_id: '<string>'}]
},
properties: {}
})
};
fetch('https://api.clix.so/api/v1/campaigns/{campaign_id}: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://api.clix.so/api/v1/campaigns/{campaign_id}: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([
'audience' => [
'broadcast' => true,
'targets' => [
[
'project_user_id' => '<string>',
'device_id' => '<string>'
]
]
],
'properties' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Clix-API-Key: <api-key>",
"X-Clix-Project-ID: <api-key>"
],
]);
$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://api.clix.so/api/v1/campaigns/{campaign_id}:trigger"
payload := strings.NewReader("{\n \"audience\": {\n \"broadcast\": true,\n \"targets\": [\n {\n \"project_user_id\": \"<string>\",\n \"device_id\": \"<string>\"\n }\n ]\n },\n \"properties\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Clix-Project-ID", "<api-key>")
req.Header.Add("X-Clix-API-Key", "<api-key>")
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://api.clix.so/api/v1/campaigns/{campaign_id}:trigger")
.header("X-Clix-Project-ID", "<api-key>")
.header("X-Clix-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"audience\": {\n \"broadcast\": true,\n \"targets\": [\n {\n \"project_user_id\": \"<string>\",\n \"device_id\": \"<string>\"\n }\n ]\n },\n \"properties\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.clix.so/api/v1/campaigns/{campaign_id}:trigger")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Clix-Project-ID"] = '<api-key>'
request["X-Clix-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"audience\": {\n \"broadcast\": true,\n \"targets\": [\n {\n \"project_user_id\": \"<string>\",\n \"device_id\": \"<string>\"\n }\n ]\n },\n \"properties\": {}\n}"
response = http.request(request)
puts response.read_body{
"trigger_id": "<string>"
}"Campaign Id must be provided"Overview
Triggers an API-triggered campaign to send messages to a specific audience. This endpoint allows you to send immediate, one-off messages to designated users or broadcast to your entire audience using a pre-configured campaign. For a comprehensive guide on setting up and using API-triggered campaigns, see the API-Triggered Campaigns guide.Authentication
This endpoint requires authentication via the following HTTP headers:X-Clix-Project-ID: Your project IDX-Clix-API-Key: Your Clix Secret API Key
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
campaign_id | string | Yes | The unique identifier of the campaign to trigger |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
audience | object | No | Defines the target audience for this campaign trigger |
properties | map | No | Custom properties to pass to the campaign for personalization |
Audience Object
| Field | Type | Required | Description |
|---|---|---|---|
broadcast | boolean | No | If true, sends to all users matching the campaign’s segment definition. Ignores targets if set. Default: false |
targets | array | No | Array of specific users/devices to target. Only users matching the campaign’s segment definition will receive the message. Ignored if broadcast is true. |
Target Object
Each target should specify one of the following:| Field | Type | Description |
|---|---|---|
project_user_id | string | Target a user by your project’s user ID |
device_id | string | Target a specific device by ID |
Properties
Custom properties are passed as key-value pairs and can be used for:- Message personalization: Insert values in message templates using
{{ trigger.property_name }} - Dynamic audience filtering: Reference values in audience conditions configured in the console
{
"name": "John Doe",
"age": 40,
"is_premium_user": true,
"state": "CA",
"city": "Mountain View"
}
Example Requests
Broadcast to All Eligible Users
Send to all users matching the campaign’s segment definition:{
"audience": {
"broadcast": true
},
"properties": {
"promotion": "Holiday Sale",
"discount": "30%"
}
}
Target Specific Users
Send to specific users, but only those who match the campaign’s segment definition:{
"audience": {
"broadcast": false,
"targets": [
{
"project_user_id": "clix_user_a"
},
{
"project_user_id": "clix_user_b"
}
]
},
"properties": {
"subscription_plan": "premium",
"message_type": "transactional"
}
}
Trigger Without Audience (Uses Campaign’s Default Audience)
{
"properties": {
"campaign_variant": "A"
}
}
Dynamic Filtering and Personalization
This example shows how to use properties for both audience filtering and message content. Campaign configuration in console:- Audience filter:
user_role == "store_staff" AND store_location == {{ trigger.store_location }} - Message title:
New pickup order - Message body:
Order #{{ trigger.order_id }} from {{ trigger.customer_name }}. {{ trigger.item_count }} items ready by {{ trigger.pickup_time }}.
{
"audience": {
"broadcast": true
},
"properties": {
"store_location": "San Francisco",
"customer_name": "Sarah Johnson",
"order_id": "ORD-12345",
"item_count": "3",
"pickup_time": "2:30 PM"
}
}
- Filter to users where
user_role == "store_staff"ANDstore_location == "San Francisco" - Send a message with title “New pickup order”
- And body “Order #ORD-12345 from Sarah Johnson. 3 items ready by 2:30 PM.”
Response
Success Response (200 OK)
Returns a trigger identifier for tracking the campaign send:{
"trigger_id": "5dbdd10e-6ea6-4ff7-836d-bd30a6d1a521"
}
trigger_id can be used to track the status and results of this specific campaign trigger.
Error Responses
400 Bad Request
Returned when:campaign_idis missing or invalid- Request body is malformed
- Failed to send campaign trigger message
Campaign Id must be provided
Failed to send campaign trigger message
401 Unauthorized
Authentication failed or invalid API key.Notes
- Campaign must be configured as “API-Triggered” in the dashboard before it can be triggered via this endpoint
- Segment Filtering: All messages are filtered by the campaign’s segment definition:
- When
broadcastistrue, the campaign sends to all users who match the campaign’s segment criteria - When
broadcastisfalse(or omitted) andtargetsare specified, only the targeted users who also match the campaign’s segment criteria will receive the message - Users who don’t match the segment criteria will not receive messages, even if explicitly targeted
- When
- When targeting specific users, you can mix different target types (device_id, user_id, project_user_id) in the same request
- Properties are optional but highly recommended for personalized messaging
- The
trigger_idin the response can be used to track delivery results and campaign analytics - Message delivery is asynchronous - the API returns immediately with a trigger_id, and messages are processed in the background
- Rate limits apply based on your project plan
Authorizations
Project ID for authentication
API Key for authentication
Path Parameters
The unique identifier of the campaign to trigger
Body
application/json
Campaign trigger configuration
Response
Campaign triggered successfully
Response containing the trigger ID
Unique identifier for this campaign trigger
Was this page helpful?