Rotate a Webhook Signing Secret
curl --request POST \
--url https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secretimport requests
url = "https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret', 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.monaco.com/v1/webhooks/subscriptions/{subscription_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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret"
req, _ := http.NewRequest("POST", url, nil)
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.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"secret": "whsec_..."
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "not_found",
"message": "Resource not found"
}
}Webhooks
Rotate a Webhook Signing Secret
Replaces the signing secret and returns the new one once. The old secret stops working immediately, and a delivery already in flight was signed with it, so accept both signatures on the receiver until traffic has settled.
Error codes
error.code | HTTP | Cause | What to do |
|---|---|---|---|
not_found | 422 | No subscription with this id exists in the calling org. | Check the id; a deleted subscription is never returned. |
POST
/
v1
/
webhooks
/
subscriptions
/
{subscription_id}
/
rotate-secret
Rotate a Webhook Signing Secret
curl --request POST \
--url https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secretimport requests
url = "https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret', 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.monaco.com/v1/webhooks/subscriptions/{subscription_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",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret"
req, _ := http.NewRequest("POST", url, nil)
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.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.monaco.com/v1/webhooks/subscriptions/{subscription_id}/rotate-secret")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"secret": "whsec_..."
},
"meta": {
"timestamp": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "not_found",
"message": "Resource not found"
}
}