更新触发器
仅修改请求体中出现的字段。传入空对象或空数组可清空集合,null 值会被拒绝(400 invalid_parameter_error)。状态变更通过暂停、恢复与归档操作进行。
更新后的 initial_events 必须全部为 user.message。若旧触发器包含其他事件类型,即使只修改无关字段,也须同时将 initial_events 替换为合法列表或 [],否则返回 400 invalid_parameter_error。
将 session_mode 从 reuse_session 切换为其他值会释放平台管理的会话绑定。触发器保持 reuse_session 时,其托管会话沿用创建时的智能体、环境与资源,因此修改 agent_id、agent_version、environment_id 或 resources 返回 400 failed_precondition_error;与当前值相同的取值会被接受。需要修改时,先将 session_mode 切换为 new_session,或新建触发器。平台管理的触发器(origin_type 已设置)与已归档的触发器拒绝更新,返回 400 failed_precondition_error。
PATCH
/
v1
/
triggers
/
{id}
更新触发器
curl --request PATCH \
--url https://api.moonshot.cn/v1/triggers/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Updated daily summary"
}
'import requests
url = "https://api.moonshot.cn/v1/triggers/{id}"
payload = { "name": "Updated daily summary" }
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({name: 'Updated daily summary'})
};
fetch('https://api.moonshot.cn/v1/triggers/{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/triggers/{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([
'name' => 'Updated daily summary'
]),
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/triggers/{id}"
payload := strings.NewReader("{\n \"name\": \"Updated daily summary\"\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/triggers/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Updated daily summary\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/triggers/{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 \"name\": \"Updated daily summary\"\n}"
response = http.request(request)
puts response.read_body{
"id": "trig_01h455vb4pex5vsknk084sn02q",
"name": "Updated daily summary",
"status": "active",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"session_mode": "new_session",
"policy": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "UTC"
},
"scope": "project",
"created_by": "user_example",
"created_at": "2026-08-01T09:00:00Z",
"updated_at": "2026-08-01T09:30:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}请求头
请求体
application/json
更新触发器的部分更新请求体:只有出现的字段会变更。状态流转不通过更新进行。请使用暂停、恢复或归档操作。
响应
应用了修改的触发器。
保存的规则,按计划或按需启动智能体。
此页面对您有帮助吗?
⌘I
更新触发器
curl --request PATCH \
--url https://api.moonshot.cn/v1/triggers/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Updated daily summary"
}
'import requests
url = "https://api.moonshot.cn/v1/triggers/{id}"
payload = { "name": "Updated daily summary" }
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({name: 'Updated daily summary'})
};
fetch('https://api.moonshot.cn/v1/triggers/{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/triggers/{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([
'name' => 'Updated daily summary'
]),
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/triggers/{id}"
payload := strings.NewReader("{\n \"name\": \"Updated daily summary\"\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/triggers/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Updated daily summary\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/triggers/{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 \"name\": \"Updated daily summary\"\n}"
response = http.request(request)
puts response.read_body{
"id": "trig_01h455vb4pex5vsknk084sn02q",
"name": "Updated daily summary",
"status": "active",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"session_mode": "new_session",
"policy": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "UTC"
},
"scope": "project",
"created_by": "user_example",
"created_at": "2026-08-01T09:00:00Z",
"updated_at": "2026-08-01T09:30:00Z"
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}