Create a webhook
curl --request POST \
--url https://api.kavenio.com/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production events",
"url": "https://example.com/kavenio/webhooks",
"events": [
"post.published",
"post.failed"
],
"secret": "whsec_test_redacted",
"isActive": true,
"customHeaders": {
"x-environment": "production"
}
}
'import requests
url = "https://api.kavenio.com/v1/webhooks"
payload = {
"name": "Production events",
"url": "https://example.com/kavenio/webhooks",
"events": ["post.published", "post.failed"],
"secret": "whsec_test_redacted",
"isActive": True,
"customHeaders": { "x-environment": "production" }
}
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: 'Production events',
url: 'https://example.com/kavenio/webhooks',
events: ['post.published', 'post.failed'],
secret: 'whsec_test_redacted',
isActive: true,
customHeaders: {'x-environment': 'production'}
})
};
fetch('https://api.kavenio.com/v1/webhooks', 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.kavenio.com/v1/webhooks",
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' => 'Production events',
'url' => 'https://example.com/kavenio/webhooks',
'events' => [
'post.published',
'post.failed'
],
'secret' => 'whsec_test_redacted',
'isActive' => true,
'customHeaders' => [
'x-environment' => 'production'
]
]),
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://api.kavenio.com/v1/webhooks"
payload := strings.NewReader("{\n \"name\": \"Production events\",\n \"url\": \"https://example.com/kavenio/webhooks\",\n \"events\": [\n \"post.published\",\n \"post.failed\"\n ],\n \"secret\": \"whsec_test_redacted\",\n \"isActive\": true,\n \"customHeaders\": {\n \"x-environment\": \"production\"\n }\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://api.kavenio.com/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production events\",\n \"url\": \"https://example.com/kavenio/webhooks\",\n \"events\": [\n \"post.published\",\n \"post.failed\"\n ],\n \"secret\": \"whsec_test_redacted\",\n \"isActive\": true,\n \"customHeaders\": {\n \"x-environment\": \"production\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kavenio.com/v1/webhooks")
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\": \"Production events\",\n \"url\": \"https://example.com/kavenio/webhooks\",\n \"events\": [\n \"post.published\",\n \"post.failed\"\n ],\n \"secret\": \"whsec_test_redacted\",\n \"isActive\": true,\n \"customHeaders\": {\n \"x-environment\": \"production\"\n }\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"url": "<string>",
"events": [],
"isActive": true,
"hasSecret": true,
"customHeaders": {},
"failureCount": 4503599627370495,
"createdBy": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"lastFiredAt": "2023-11-07T05:31:56Z",
"disabledAt": "2023-11-07T05:31:56Z"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}Webhooks
Create webhook
Creates a webhook endpoint for selected Kavenio events. The endpoint URL must use HTTPS.
POST
/
v1
/
webhooks
Create a webhook
curl --request POST \
--url https://api.kavenio.com/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Production events",
"url": "https://example.com/kavenio/webhooks",
"events": [
"post.published",
"post.failed"
],
"secret": "whsec_test_redacted",
"isActive": true,
"customHeaders": {
"x-environment": "production"
}
}
'import requests
url = "https://api.kavenio.com/v1/webhooks"
payload = {
"name": "Production events",
"url": "https://example.com/kavenio/webhooks",
"events": ["post.published", "post.failed"],
"secret": "whsec_test_redacted",
"isActive": True,
"customHeaders": { "x-environment": "production" }
}
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: 'Production events',
url: 'https://example.com/kavenio/webhooks',
events: ['post.published', 'post.failed'],
secret: 'whsec_test_redacted',
isActive: true,
customHeaders: {'x-environment': 'production'}
})
};
fetch('https://api.kavenio.com/v1/webhooks', 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.kavenio.com/v1/webhooks",
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' => 'Production events',
'url' => 'https://example.com/kavenio/webhooks',
'events' => [
'post.published',
'post.failed'
],
'secret' => 'whsec_test_redacted',
'isActive' => true,
'customHeaders' => [
'x-environment' => 'production'
]
]),
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://api.kavenio.com/v1/webhooks"
payload := strings.NewReader("{\n \"name\": \"Production events\",\n \"url\": \"https://example.com/kavenio/webhooks\",\n \"events\": [\n \"post.published\",\n \"post.failed\"\n ],\n \"secret\": \"whsec_test_redacted\",\n \"isActive\": true,\n \"customHeaders\": {\n \"x-environment\": \"production\"\n }\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://api.kavenio.com/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Production events\",\n \"url\": \"https://example.com/kavenio/webhooks\",\n \"events\": [\n \"post.published\",\n \"post.failed\"\n ],\n \"secret\": \"whsec_test_redacted\",\n \"isActive\": true,\n \"customHeaders\": {\n \"x-environment\": \"production\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kavenio.com/v1/webhooks")
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\": \"Production events\",\n \"url\": \"https://example.com/kavenio/webhooks\",\n \"events\": [\n \"post.published\",\n \"post.failed\"\n ],\n \"secret\": \"whsec_test_redacted\",\n \"isActive\": true,\n \"customHeaders\": {\n \"x-environment\": \"production\"\n }\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"data": {
"id": "<string>",
"organizationId": "<string>",
"name": "<string>",
"url": "<string>",
"events": [],
"isActive": true,
"hasSecret": true,
"customHeaders": {},
"failureCount": 4503599627370495,
"createdBy": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"lastFiredAt": "2023-11-07T05:31:56Z",
"disabledAt": "2023-11-07T05:31:56Z"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}{
"ok": true,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Required string length:
1 - 160Required array length:
1 - 12 elementsAvailable options:
post.scheduled, post.updated, post.published, post.unpublished, post.failed, post.partial, post.recycled, account.connected, account.disconnected, ad.created, ad.status_changed, account.ads.initial_sync_completed Required string length:
8 - 1024Show child attributes
Show child attributes
Was this page helpful?
⌘I