Create a webhook.
curl --request POST \
--url https://{tenant}/api/hooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"header_map": {
"another-value": "somevalue",
"secret": "superscretkey"
},
"method": "POST",
"name": "Expired Keys webhook",
"target_path": "https://httpbin.org/expired-keys"
}
'import requests
url = "https://{tenant}/api/hooks"
payload = {
"header_map": {
"another-value": "somevalue",
"secret": "superscretkey"
},
"method": "POST",
"name": "Expired Keys webhook",
"target_path": "https://httpbin.org/expired-keys"
}
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({
header_map: {'another-value': 'somevalue', secret: 'superscretkey'},
method: 'POST',
name: 'Expired Keys webhook',
target_path: 'https://httpbin.org/expired-keys'
})
};
fetch('https://{tenant}/api/hooks', 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://{tenant}/api/hooks",
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([
'header_map' => [
'another-value' => 'somevalue',
'secret' => 'superscretkey'
],
'method' => 'POST',
'name' => 'Expired Keys webhook',
'target_path' => 'https://httpbin.org/expired-keys'
]),
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://{tenant}/api/hooks"
payload := strings.NewReader("{\n \"header_map\": {\n \"another-value\": \"somevalue\",\n \"secret\": \"superscretkey\"\n },\n \"method\": \"POST\",\n \"name\": \"Expired Keys webhook\",\n \"target_path\": \"https://httpbin.org/expired-keys\"\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://{tenant}/api/hooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"header_map\": {\n \"another-value\": \"somevalue\",\n \"secret\": \"superscretkey\"\n },\n \"method\": \"POST\",\n \"name\": \"Expired Keys webhook\",\n \"target_path\": \"https://httpbin.org/expired-keys\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/hooks")
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 \"header_map\": {\n \"another-value\": \"somevalue\",\n \"secret\": \"superscretkey\"\n },\n \"method\": \"POST\",\n \"name\": \"Expired Keys webhook\",\n \"target_path\": \"https://httpbin.org/expired-keys\"\n}"
response = http.request(request)
puts response.read_body{
"Message": "Webhook created",
"Meta": null,
"Status": "OK"
}{
"Message": "Webhook object validation failed.",
"Meta": null,
"Status": "Error"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "Request body malformed.",
"Meta": null,
"Status": "Error"
}{
"Message": "Duplicate webhook_id.",
"Meta": null,
"Status": "Error"
}{
"Message": "Failed to read response body, body empty.",
"Meta": null,
"Status": "Error"
}Webhooks
Create a webhook.
Create a webhook. The webhook method and target_path fields are required. Method can either be DELETE,GET,PUT,POST or PATCH.
POST
/
api
/
hooks
Create a webhook.
curl --request POST \
--url https://{tenant}/api/hooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"header_map": {
"another-value": "somevalue",
"secret": "superscretkey"
},
"method": "POST",
"name": "Expired Keys webhook",
"target_path": "https://httpbin.org/expired-keys"
}
'import requests
url = "https://{tenant}/api/hooks"
payload = {
"header_map": {
"another-value": "somevalue",
"secret": "superscretkey"
},
"method": "POST",
"name": "Expired Keys webhook",
"target_path": "https://httpbin.org/expired-keys"
}
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({
header_map: {'another-value': 'somevalue', secret: 'superscretkey'},
method: 'POST',
name: 'Expired Keys webhook',
target_path: 'https://httpbin.org/expired-keys'
})
};
fetch('https://{tenant}/api/hooks', 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://{tenant}/api/hooks",
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([
'header_map' => [
'another-value' => 'somevalue',
'secret' => 'superscretkey'
],
'method' => 'POST',
'name' => 'Expired Keys webhook',
'target_path' => 'https://httpbin.org/expired-keys'
]),
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://{tenant}/api/hooks"
payload := strings.NewReader("{\n \"header_map\": {\n \"another-value\": \"somevalue\",\n \"secret\": \"superscretkey\"\n },\n \"method\": \"POST\",\n \"name\": \"Expired Keys webhook\",\n \"target_path\": \"https://httpbin.org/expired-keys\"\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://{tenant}/api/hooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"header_map\": {\n \"another-value\": \"somevalue\",\n \"secret\": \"superscretkey\"\n },\n \"method\": \"POST\",\n \"name\": \"Expired Keys webhook\",\n \"target_path\": \"https://httpbin.org/expired-keys\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}/api/hooks")
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 \"header_map\": {\n \"another-value\": \"somevalue\",\n \"secret\": \"superscretkey\"\n },\n \"method\": \"POST\",\n \"name\": \"Expired Keys webhook\",\n \"target_path\": \"https://httpbin.org/expired-keys\"\n}"
response = http.request(request)
puts response.read_body{
"Message": "Webhook created",
"Meta": null,
"Status": "OK"
}{
"Message": "Webhook object validation failed.",
"Meta": null,
"Status": "Error"
}{
"Message": "Not authorised",
"Meta": null,
"Status": "Error"
}{
"Message": "Request body malformed.",
"Meta": null,
"Status": "Error"
}{
"Message": "Duplicate webhook_id.",
"Meta": null,
"Status": "Error"
}{
"Message": "Failed to read response body, body empty.",
"Meta": null,
"Status": "Error"
}Was this page helpful?
⌘I