curl --request POST \
--url https://api.affinity.co/v2/webhooks/{webhookId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/affinity-events",
"subscriptions": [
"list.created"
],
"status": "active"
}
'import requests
url = "https://api.affinity.co/v2/webhooks/{webhookId}"
payload = {
"url": "https://example.com/affinity-events",
"subscriptions": ["list.created"],
"status": "active"
}
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({
url: 'https://example.com/affinity-events',
subscriptions: ['list.created'],
status: 'active'
})
};
fetch('https://api.affinity.co/v2/webhooks/{webhookId}', 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.affinity.co/v2/webhooks/{webhookId}",
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([
'url' => 'https://example.com/affinity-events',
'subscriptions' => [
'list.created'
],
'status' => 'active'
]),
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.affinity.co/v2/webhooks/{webhookId}"
payload := strings.NewReader("{\n \"url\": \"https://example.com/affinity-events\",\n \"subscriptions\": [\n \"list.created\"\n ],\n \"status\": \"active\"\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.affinity.co/v2/webhooks/{webhookId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/affinity-events\",\n \"subscriptions\": [\n \"list.created\"\n ],\n \"status\": \"active\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/webhooks/{webhookId}")
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 \"url\": \"https://example.com/affinity-events\",\n \"subscriptions\": [\n \"list.created\"\n ],\n \"status\": \"active\"\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Update a Webhook
| ⚠️ This endpoint is currently in BETA |
|---|
Updates a Webhook. Only provided fields are changed; omitted fields keep their current value.
Changing url on an active webhook, or setting status to active on a disabled webhook, triggers a test delivery that validates the URL before the update is applied. URLs containing embedded credentials are rejected.
Only the webhook’s creator, or a user allowed to manage all webhooks, may update it.
curl --request POST \
--url https://api.affinity.co/v2/webhooks/{webhookId} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/affinity-events",
"subscriptions": [
"list.created"
],
"status": "active"
}
'import requests
url = "https://api.affinity.co/v2/webhooks/{webhookId}"
payload = {
"url": "https://example.com/affinity-events",
"subscriptions": ["list.created"],
"status": "active"
}
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({
url: 'https://example.com/affinity-events',
subscriptions: ['list.created'],
status: 'active'
})
};
fetch('https://api.affinity.co/v2/webhooks/{webhookId}', 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.affinity.co/v2/webhooks/{webhookId}",
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([
'url' => 'https://example.com/affinity-events',
'subscriptions' => [
'list.created'
],
'status' => 'active'
]),
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.affinity.co/v2/webhooks/{webhookId}"
payload := strings.NewReader("{\n \"url\": \"https://example.com/affinity-events\",\n \"subscriptions\": [\n \"list.created\"\n ],\n \"status\": \"active\"\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.affinity.co/v2/webhooks/{webhookId}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/affinity-events\",\n \"subscriptions\": [\n \"list.created\"\n ],\n \"status\": \"active\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.affinity.co/v2/webhooks/{webhookId}")
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 \"url\": \"https://example.com/affinity-events\",\n \"subscriptions\": [\n \"list.created\"\n ],\n \"status\": \"active\"\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}Authorizations
A static Affinity API key, presented as a bearer token.
Path Parameters
Webhook ID
1 <= x <= 9007199254740991Body
Partial-update request body for a webhook. Only provided properties are updated. Changing url on an active webhook, or setting status to active on a disabled webhook, triggers a test delivery that validates the URL before the update is applied.
New delivery URL for the webhook. Must be unique within the organization.
"https://example.com/affinity-events"
New set of event types the webhook receives. An empty array subscribes the webhook to all event types.
100An event type a webhook can subscribe to. Values match the type field of delivered webhook payloads and are shared with the v1 webhook API.
list.created, list.updated, list.deleted, list_entry.created, list_entry.deleted, note.created, note.updated, note.deleted, field.created, field.updated, field.deleted, field_value.created, field_value.updated, field_value.deleted, person.created, person.updated, person.deleted, organization.created, organization.updated, organization.deleted, organization.merged, opportunity.created, opportunity.updated, opportunity.deleted, file.created, file.deleted, smart_interaction_value.updated, reminder.created, reminder.updated, reminder.deleted Set to disabled to pause event delivery, or active to resume it.
active, disabled "active"
Response
No Content
Related topics
Create a WebhookDelete a WebhookGet a single WebhookGet all WebhooksUpdate a single NoteWas this page helpful?