更新 Webhook
更新指定配置字段,对后续事件生效。已有事件继续使用原地址和签名密钥。修改地址不改变 Webhook 的启用状态。启用 Webhook 会清除 disabled_reason。空请求体返回 400 invalid_request_error。
PATCH
/
v1
/
webhooks
/
{id}
更新 Webhook
curl --request PATCH \
--url https://api.moonshot.cn/v1/webhooks/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"enabled": true
}
'import requests
url = "https://api.moonshot.cn/v1/webhooks/{id}"
payload = { "enabled": True }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({enabled: true})
};
fetch('https://api.moonshot.cn/v1/webhooks/{id}', 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.moonshot.cn/v1/webhooks/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true
]),
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.moonshot.cn/v1/webhooks/{id}"
payload := strings.NewReader("{\n \"enabled\": true\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.moonshot.cn/v1/webhooks/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/webhooks/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "webhook_01h455vb4pex5vsknk084sn02q",
"name": "Production events",
"url": "https://example.invalid/hook",
"event_types": [
"agent.updated",
"session.status_idled"
],
"enabled": true,
"created_at": "2026-11-05T00:00:00Z",
"updated_at": "2026-11-05T00:01:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "permission_denied_error",
"message": "The caller cannot perform this operation.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}请求头
请求体
application/json
要更新的 Webhook 配置字段。
Webhook 配置变更。未提供的字段保持不变,至少提供一个字段,字段值不能为 null。
订阅的业务事件类型,至少指定一项,不能重复。
Minimum array length:
1Webhook 可订阅的业务事件类型。
可用选项:
session.status_run_started, session.status_idled, session.status_terminated, session.thread_created, session.thread_idled, session.thread_terminated, session.updated, session.deleted, vault.created, vault.archived, vault.deleted, vault_credential.created, vault_credential.archived, vault_credential.deleted, vault_credential.refresh_failed, agent.created, agent.updated, agent.archived, trigger.created, trigger.updated, trigger.paused, trigger.unpaused, trigger.archived, trigger_run.started, trigger_run.succeeded, trigger_run.failed, trigger_run.skipped, environment.created, environment.updated, environment.build_ended, environment.archived, environment.deleted, memory_store.created, memory_store.archived, memory_store.deleted 示例:
["agent.updated"]
响应
Webhook 已更新。
项目的 Webhook 配置。
此 Webhook 订阅的业务事件类型。
Webhook 可订阅的业务事件类型。
可用选项:
session.status_run_started, session.status_idled, session.status_terminated, session.thread_created, session.thread_idled, session.thread_terminated, session.updated, session.deleted, vault.created, vault.archived, vault.deleted, vault_credential.created, vault_credential.archived, vault_credential.deleted, vault_credential.refresh_failed, agent.created, agent.updated, agent.archived, trigger.created, trigger.updated, trigger.paused, trigger.unpaused, trigger.archived, trigger_run.started, trigger_run.succeeded, trigger_run.failed, trigger_run.skipped, environment.created, environment.updated, environment.build_ended, environment.archived, environment.deleted, memory_store.created, memory_store.archived, memory_store.deleted 示例:
["agent.updated", "session.status_idled"]
此页面对您有帮助吗?
⌘I
更新 Webhook
curl --request PATCH \
--url https://api.moonshot.cn/v1/webhooks/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"enabled": true
}
'import requests
url = "https://api.moonshot.cn/v1/webhooks/{id}"
payload = { "enabled": True }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({enabled: true})
};
fetch('https://api.moonshot.cn/v1/webhooks/{id}', 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.moonshot.cn/v1/webhooks/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'enabled' => true
]),
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.moonshot.cn/v1/webhooks/{id}"
payload := strings.NewReader("{\n \"enabled\": true\n}")
req, _ := http.NewRequest("PATCH", 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.patch("https://api.moonshot.cn/v1/webhooks/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/webhooks/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "webhook_01h455vb4pex5vsknk084sn02q",
"name": "Production events",
"url": "https://example.invalid/hook",
"event_types": [
"agent.updated",
"session.status_idled"
],
"enabled": true,
"created_at": "2026-11-05T00:00:00Z",
"updated_at": "2026-11-05T00:01:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "permission_denied_error",
"message": "The caller cannot perform this operation.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}