Rotate a webhook endpoint secret
curl --request POST \
--url https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '{
"force": false
}'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"force\": false\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({force: false})
};
fetch('https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret"
payload := strings.NewReader("{\n \"force\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-Api-Key", "<api-key>")
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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret",
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([
'force' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret"
payload = { "force": False }
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"webhook_endpoint": {
"id": 66,
"name": "My webhook",
"url": "https://hooks.example.com/incoming",
"events": [
"subscriber.created"
],
"status": "active",
"source": "creator",
"description": "A test webhook",
"created_by_app": null,
"created_at": "2023-02-17T11:43:55Z",
"previous_secret_expires_at": "2023-02-18T11:43:55Z",
"secret": "whsec_YOUR_SIGNING_SECRET_HERE"
}
}{
"errors": [
"Not Found"
]
}{
"errors": [
"The previous signing secret is still within its rotation window."
]
}Webhooks
Rotate a webhook endpoint secret
Generates a new signing secret for the endpoint and returns it. The response is the only time the new secret appears in plaintext — store it securely.
To avoid dropping deliveries mid-rollout, the previous secret keeps verifying until the overlap window closes (the endpoint’s previous_secret_expires_at). During the window every delivery is signed with both secrets, so the X-Kit-Signature header carries two v1 entries — see secret rotation.
Rotating again while a previous rotation’s window is still open returns 409; pass force: true to rotate anyway and immediately expire the older secret. Once you’ve switched over, you can close the window early with Revoke the previous secret.
POST
/
v4
/
webhook_endpoints
/
{id}
/
rotate_secret
Rotate a webhook endpoint secret
curl --request POST \
--url https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret \
--header 'Content-Type: application/json' \
--header 'X-Kit-Api-Key: <api-key>' \
--data '{
"force": false
}'require 'uri'
require 'net/http'
url = URI("https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Kit-Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"force\": false\n}"
response = http.request(request)
puts response.read_bodyconst options = {
method: 'POST',
headers: {'X-Kit-Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({force: false})
};
fetch('https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret"
payload := strings.NewReader("{\n \"force\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Kit-Api-Key", "<api-key>")
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))
}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret",
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([
'force' => false
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Kit-Api-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}import requests
url = "https://api.kit.com/v4/webhook_endpoints/{id}/rotate_secret"
payload = { "force": False }
headers = {
"X-Kit-Api-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"webhook_endpoint": {
"id": 66,
"name": "My webhook",
"url": "https://hooks.example.com/incoming",
"events": [
"subscriber.created"
],
"status": "active",
"source": "creator",
"description": "A test webhook",
"created_by_app": null,
"created_at": "2023-02-17T11:43:55Z",
"previous_secret_expires_at": "2023-02-18T11:43:55Z",
"secret": "whsec_YOUR_SIGNING_SECRET_HERE"
}
}{
"errors": [
"Not Found"
]
}{
"errors": [
"The previous signing secret is still within its rotation window."
]
}Authorizations
API KeyOAuth2
Body
application/json
Was this page helpful?