Update a webhook subscription
curl --request PUT \
--url https://notificationservice-staging.withbenji.com/webhooks/subscribe \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"endpoint": "<string>",
"event_name": "<string>",
"entity_type": 123
}
'import requests
url = "https://notificationservice-staging.withbenji.com/webhooks/subscribe"
payload = {
"endpoint": "<string>",
"event_name": "<string>",
"entity_type": 123
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({endpoint: '<string>', event_name: '<string>', entity_type: 123})
};
fetch('https://notificationservice-staging.withbenji.com/webhooks/subscribe', 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://notificationservice-staging.withbenji.com/webhooks/subscribe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'endpoint' => '<string>',
'event_name' => '<string>',
'entity_type' => 123
]),
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://notificationservice-staging.withbenji.com/webhooks/subscribe"
payload := strings.NewReader("{\n \"endpoint\": \"<string>\",\n \"event_name\": \"<string>\",\n \"entity_type\": 123\n}")
req, _ := http.NewRequest("PUT", 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.put("https://notificationservice-staging.withbenji.com/webhooks/subscribe")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"endpoint\": \"<string>\",\n \"event_name\": \"<string>\",\n \"entity_type\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://notificationservice-staging.withbenji.com/webhooks/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"endpoint\": \"<string>\",\n \"event_name\": \"<string>\",\n \"entity_type\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"subscribed": true
}
}
{
"error": "invalid_subscription",
"message": "Invalid entity or event"
}
{
"error": "unauthorized_partner",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "event_not_exists",
"message": "The specified event subscription does not exist"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
Webhooks
Update a webhook subscription
Update a webhook subscription for a specific event or all entity events on the Benji Platform
PUT
/
webhooks
/
subscribe
Update a webhook subscription
curl --request PUT \
--url https://notificationservice-staging.withbenji.com/webhooks/subscribe \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"endpoint": "<string>",
"event_name": "<string>",
"entity_type": 123
}
'import requests
url = "https://notificationservice-staging.withbenji.com/webhooks/subscribe"
payload = {
"endpoint": "<string>",
"event_name": "<string>",
"entity_type": 123
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({endpoint: '<string>', event_name: '<string>', entity_type: 123})
};
fetch('https://notificationservice-staging.withbenji.com/webhooks/subscribe', 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://notificationservice-staging.withbenji.com/webhooks/subscribe",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'endpoint' => '<string>',
'event_name' => '<string>',
'entity_type' => 123
]),
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://notificationservice-staging.withbenji.com/webhooks/subscribe"
payload := strings.NewReader("{\n \"endpoint\": \"<string>\",\n \"event_name\": \"<string>\",\n \"entity_type\": 123\n}")
req, _ := http.NewRequest("PUT", 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.put("https://notificationservice-staging.withbenji.com/webhooks/subscribe")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"endpoint\": \"<string>\",\n \"event_name\": \"<string>\",\n \"entity_type\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://notificationservice-staging.withbenji.com/webhooks/subscribe")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"endpoint\": \"<string>\",\n \"event_name\": \"<string>\",\n \"entity_type\": 123\n}"
response = http.request(request)
puts response.read_body{
"code": "ok",
"data": {
"subscribed": true
}
}
{
"error": "invalid_subscription",
"message": "Invalid entity or event"
}
{
"error": "unauthorized_partner",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "event_not_exists",
"message": "The specified event subscription does not exist"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
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
Your endpoint URL that will receive the event webhooks
string
The event you are subscribing to. Note that if an event is not specified, all events for the entity type specified will be subscribed to.
integer
Integer representing an enum of one of the following entity type values to subscribe to:
Show possible entity type values
Show possible entity type values
- USER (1) : Indicating a user entity
- CAMPAIGN (2) : Indicating a campaign entity
- TRANSACTION (3) : Indicating a reward transaction entity
To delete an endpoint subscription, just use this API with an empty endpoint parameter.
Return values
boolean
required
A true or false value indicating whether the subscription was successful.
{
"code": "ok",
"data": {
"subscribed": true
}
}
{
"error": "invalid_subscription",
"message": "Invalid entity or event"
}
{
"error": "unauthorized_partner",
"message": "Invalid key, or key is not authorized to make this call"
}
{
"error": "event_not_exists",
"message": "The specified event subscription does not exist"
}
{
"error": "unexpected_error",
"message": "An unexpected error has occurred"
}
Was this page helpful?
⌘I