Register a webhook endpoint
curl --request POST \
--url https://api.farthing.ai/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/hooks/farthing",
"label": "prod"
}
'import requests
url = "https://api.farthing.ai/v1/webhooks"
payload = {
"url": "https://example.com/hooks/farthing",
"label": "prod"
}
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/hooks/farthing', label: 'prod'})
};
fetch('https://api.farthing.ai/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.farthing.ai/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([
'url' => 'https://example.com/hooks/farthing',
'label' => 'prod'
]),
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.farthing.ai/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://example.com/hooks/farthing\",\n \"label\": \"prod\"\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.farthing.ai/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/hooks/farthing\",\n \"label\": \"prod\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.farthing.ai/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 \"url\": \"https://example.com/hooks/farthing\",\n \"label\": \"prod\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3d4c5b6a-7890-4123-9abc-def012345678",
"url": "https://example.com/hooks/farthing",
"label": "prod",
"secret": "whsec_1a2B3c4D5e6F7g8H9i0JkLmNoPqRsTuV"
}Webhooks
Register a webhook endpoint
The signing secret is returned exactly once, here. Store it — nothing can recover it.
Requires the webhooks.write scope.
A subject-bound key cannot manage webhook endpoints. One endpoint receives the transitions of every checkout the tenant runs, for every end user, so registering or reading them from a single person’s key would be a way to subscribe to everyone else’s activity. 403.
POST
/
v1
/
webhooks
Register a webhook endpoint
curl --request POST \
--url https://api.farthing.ai/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://example.com/hooks/farthing",
"label": "prod"
}
'import requests
url = "https://api.farthing.ai/v1/webhooks"
payload = {
"url": "https://example.com/hooks/farthing",
"label": "prod"
}
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/hooks/farthing', label: 'prod'})
};
fetch('https://api.farthing.ai/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.farthing.ai/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([
'url' => 'https://example.com/hooks/farthing',
'label' => 'prod'
]),
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.farthing.ai/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"https://example.com/hooks/farthing\",\n \"label\": \"prod\"\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.farthing.ai/v1/webhooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://example.com/hooks/farthing\",\n \"label\": \"prod\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.farthing.ai/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 \"url\": \"https://example.com/hooks/farthing\",\n \"label\": \"prod\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3d4c5b6a-7890-4123-9abc-def012345678",
"url": "https://example.com/hooks/farthing",
"label": "prod",
"secret": "whsec_1a2B3c4D5e6F7g8H9i0JkLmNoPqRsTuV"
}Authorizations
Authorization: Bearer ck_test_… or ck_live_…. There is no other auth scheme — no query-string keys, no request signing, no OAuth.
Body
application/json