curl --request POST \
--url https://api.1club.ai/v1/platform/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"eventTypes": [
"membership.cancelled"
],
"clubIds": [
123
],
"description": "<string>"
}
'import requests
url = "https://api.1club.ai/v1/platform/webhooks"
payload = {
"url": "<string>",
"eventTypes": ["membership.cancelled"],
"clubIds": [123],
"description": "<string>"
}
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: '<string>',
eventTypes: ['membership.cancelled'],
clubIds: [123],
description: '<string>'
})
};
fetch('https://api.1club.ai/v1/platform/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.1club.ai/v1/platform/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([
'url' => '<string>',
'eventTypes' => [
'membership.cancelled'
],
'clubIds' => [
123
],
'description' => '<string>'
]),
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.1club.ai/v1/platform/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"eventTypes\": [\n \"membership.cancelled\"\n ],\n \"clubIds\": [\n 123\n ],\n \"description\": \"<string>\"\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.1club.ai/v1/platform/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"eventTypes\": [\n \"membership.cancelled\"\n ],\n \"clubIds\": [\n 123\n ],\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.1club.ai/v1/platform/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 \"url\": \"<string>\",\n \"eventTypes\": [\n \"membership.cancelled\"\n ],\n \"clubIds\": [\n 123\n ],\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"url": "<string>",
"description": "<string>",
"enabled": true,
"eventTypes": [
"membership.cancelled"
],
"clubIds": [
123
],
"signingSecretPrefix": "<string>",
"disabledReason": "<string>",
"createdByApiTokenId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"signingSecret": "<string>"
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}Create a webhook endpoint
Subscribes url to the events in eventTypes. Each event is a signed JSON POST to the address, carrying the event’s id and type and the ids of what changed, never the record: read it with the platform API under your own scopes. The response holds the signingSecret the deliveries are signed with (1Club-Signature). It is shown once, here, and cannot be read again.
url must be a public https address: a private, loopback, internal or reserved host, a name with no dot (metadata), or an address carrying a username and password is refused with a 400. Creating the endpoint looks up no name: the address is checked again on every delivery, and an attempt to a name that resolves to a private address fails like any other failed attempt. A delivery does not follow a redirect (a 3xx answer is a failed attempt).
Subscribing needs, besides webhooks:write, the read scope of what each event reports, as reading it does: contacts:read for contact.*, memberships:read for membership.*, transactions:read for charge.*, bookings:read for booking.*, checkins:read for checkin.*, signed-documents:read for document.* and areas:read for availability.changed. A key that lacks one is refused with a 403 and the code WEBHOOK_EVENT_SCOPE_MISSING, naming the scopes in details.requiredScopes. A key that expires, or loses one of those scopes or both webhooks scopes, stops receiving: the events already waiting to be sent to it are dropped too.
The endpoint belongs to this API key: the key lists, reads and deletes it, and revoking the key deletes it. clubIds limits it to those clubs (each one of the organization’s); omit it for every club. An event that belongs to no club, such as a contact or a tag, is always sent. An organization can have at most 50 endpoints.
A receiver that answers 410 Gone to a delivery ends the subscription: the endpoint is deleted at once. Any other failure is retried over about 33 hours, and an endpoint that keeps failing is switched off.
Not available to an OAuth connection (WEBHOOKS_REQUIRE_API_KEY): manage endpoints in the admin there.
The response is never stored for replay, so the secret is never kept: an Idempotency-Key cannot replay it. The key is still claimed while the request runs. A retry after an answer creates a second endpoint (delete the extra one, or do not retry a create that got an answer). A retry while the first request is still running, or just after it answered, or after the connection dropped before the answer, gets 409, and so does a key already used for a different request.
curl --request POST \
--url https://api.1club.ai/v1/platform/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "<string>",
"eventTypes": [
"membership.cancelled"
],
"clubIds": [
123
],
"description": "<string>"
}
'import requests
url = "https://api.1club.ai/v1/platform/webhooks"
payload = {
"url": "<string>",
"eventTypes": ["membership.cancelled"],
"clubIds": [123],
"description": "<string>"
}
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: '<string>',
eventTypes: ['membership.cancelled'],
clubIds: [123],
description: '<string>'
})
};
fetch('https://api.1club.ai/v1/platform/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.1club.ai/v1/platform/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([
'url' => '<string>',
'eventTypes' => [
'membership.cancelled'
],
'clubIds' => [
123
],
'description' => '<string>'
]),
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.1club.ai/v1/platform/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"eventTypes\": [\n \"membership.cancelled\"\n ],\n \"clubIds\": [\n 123\n ],\n \"description\": \"<string>\"\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.1club.ai/v1/platform/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"eventTypes\": [\n \"membership.cancelled\"\n ],\n \"clubIds\": [\n 123\n ],\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.1club.ai/v1/platform/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 \"url\": \"<string>\",\n \"eventTypes\": [\n \"membership.cancelled\"\n ],\n \"clubIds\": [\n 123\n ],\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"url": "<string>",
"description": "<string>",
"enabled": true,
"eventTypes": [
"membership.cancelled"
],
"clubIds": [
123
],
"signingSecretPrefix": "<string>",
"disabledReason": "<string>",
"createdByApiTokenId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"signingSecret": "<string>"
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}{
"error": "<string>",
"code": "<string>",
"details": {}
}Authorizations
Body
Where to send the events. Must be a public https address: a private, loopback, internal or reserved host, a name with no dot, or an address with a username and password is refused. It is checked again on every delivery, and a redirect is not followed.
2048The events to receive. The key also needs the read scope of what each reports: contacts:read for contact.*, memberships:read for membership.*, transactions:read for charge.*, bookings:read for booking.*, checkins:read for checkin.*, signed-documents:read for document.*, areas:read for availability.changed.
1An event type, such as contact.created, membership.cancelled or availability.changed. GET /v1/platform/webhooks/event-types lists them all.
Response
Endpoint created; the signing secret is in this response only
Was this page helpful?