Send Trigger Event
curl --request POST \
--url https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"trigger_name": "<string>",
"external_user_id": "<string>",
"user_uuid": "<string>",
"transaction_context": {}
}
'import requests
url = "https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers"
payload = {
"trigger_name": "<string>",
"external_user_id": "<string>",
"user_uuid": "<string>",
"transaction_context": {}
}
headers = {
"x-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-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
trigger_name: '<string>',
external_user_id: '<string>',
user_uuid: '<string>',
transaction_context: {}
})
};
fetch('https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers', 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-staging.withbenji.com/partnerships/{partnership_id}/triggers",
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([
'trigger_name' => '<string>',
'external_user_id' => '<string>',
'user_uuid' => '<string>',
'transaction_context' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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-staging.withbenji.com/partnerships/{partnership_id}/triggers"
payload := strings.NewReader("{\n \"trigger_name\": \"<string>\",\n \"external_user_id\": \"<string>\",\n \"user_uuid\": \"<string>\",\n \"transaction_context\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-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-staging.withbenji.com/partnerships/{partnership_id}/triggers")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"trigger_name\": \"<string>\",\n \"external_user_id\": \"<string>\",\n \"user_uuid\": \"<string>\",\n \"transaction_context\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"trigger_name\": \"<string>\",\n \"external_user_id\": \"<string>\",\n \"user_uuid\": \"<string>\",\n \"transaction_context\": {}\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"trigger_event_id": "f0f8ae48-f005-471c-9a15-ec53c207218c"
}
}
{
"code": "invalid_token",
"message": "Invalid token"
}
{
"code": "unauthorized_request",
"message": "Token is not authorized to make this request"
}
{
"code": "partnership_does_not_exist",
"message": "The partnership does not exist"
}
Partnerships
Send Trigger Event
Process a trigger event for a partnership to initiate campaign reward evaluation
POST
/
partnerships
/
{partnership_id}
/
triggers
Send Trigger Event
curl --request POST \
--url https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"trigger_name": "<string>",
"external_user_id": "<string>",
"user_uuid": "<string>",
"transaction_context": {}
}
'import requests
url = "https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers"
payload = {
"trigger_name": "<string>",
"external_user_id": "<string>",
"user_uuid": "<string>",
"transaction_context": {}
}
headers = {
"x-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-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
trigger_name: '<string>',
external_user_id: '<string>',
user_uuid: '<string>',
transaction_context: {}
})
};
fetch('https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers', 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-staging.withbenji.com/partnerships/{partnership_id}/triggers",
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([
'trigger_name' => '<string>',
'external_user_id' => '<string>',
'user_uuid' => '<string>',
'transaction_context' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <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-staging.withbenji.com/partnerships/{partnership_id}/triggers"
payload := strings.NewReader("{\n \"trigger_name\": \"<string>\",\n \"external_user_id\": \"<string>\",\n \"user_uuid\": \"<string>\",\n \"transaction_context\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-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-staging.withbenji.com/partnerships/{partnership_id}/triggers")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"trigger_name\": \"<string>\",\n \"external_user_id\": \"<string>\",\n \"user_uuid\": \"<string>\",\n \"transaction_context\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-staging.withbenji.com/partnerships/{partnership_id}/triggers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"trigger_name\": \"<string>\",\n \"external_user_id\": \"<string>\",\n \"user_uuid\": \"<string>\",\n \"transaction_context\": {}\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"trigger_event_id": "f0f8ae48-f005-471c-9a15-ec53c207218c"
}
}
{
"code": "invalid_token",
"message": "Invalid token"
}
{
"code": "unauthorized_request",
"message": "Token is not authorized to make this request"
}
{
"code": "partnership_does_not_exist",
"message": "The partnership does not exist"
}
The
x-api-key header value to be used on this API is your partner API key, which can be generated through the dashboard.string
required
The unique identifier of the partnership associated with this trigger event.
string
required
The name of the trigger event to process. This identifies the type of event being triggered (e.g., ‘user_signup’, ‘transaction_completed’). Trigger name can be found in the triggers section of the Pilot dashboard.
string
Your external identifier of the user. Used to map the event to a specific user in the Benji platform.
string
The unique Benji identifier of the user associated with this trigger event.
object
Additional context data about the transaction that triggered this event. Contains partner-specific information about the transaction details as configured on the trigger in the triggers section on Pilot.
Response
string
required
The UUID of the trigger event. This is the preferred identifier for referencing the trigger event.
{
"code": "ok",
"data": {
"trigger_event_id": "f0f8ae48-f005-471c-9a15-ec53c207218c"
}
}
{
"code": "invalid_token",
"message": "Invalid token"
}
{
"code": "unauthorized_request",
"message": "Token is not authorized to make this request"
}
{
"code": "partnership_does_not_exist",
"message": "The partnership does not exist"
}
Trigger events are used to activate campaign flows and generate rewards for users. Make sure the trigger is configured in your partnership settings before sending events.
Was this page helpful?
⌘I