curl --request POST \
--url https://api.moonshot.cn/v1/triggers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Daily summary",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"policy": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "UTC"
}
}
'import requests
url = "https://api.moonshot.cn/v1/triggers"
payload = {
"name": "Daily summary",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"policy": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "UTC"
}
}
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({
name: 'Daily summary',
agent_id: 'agent_01h455vb4pex5vsknk084sn02q',
environment_id: 'env_01h455vb4pex5vsknk084sn02q',
policy: {type: 'cron', expression: '0 9 * * *', timezone: 'UTC'}
})
};
fetch('https://api.moonshot.cn/v1/triggers', 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",
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([
'name' => 'Daily summary',
'agent_id' => 'agent_01h455vb4pex5vsknk084sn02q',
'environment_id' => 'env_01h455vb4pex5vsknk084sn02q',
'policy' => [
'type' => 'cron',
'expression' => '0 9 * * *',
'timezone' => 'UTC'
]
]),
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"
payload := strings.NewReader("{\n \"name\": \"Daily summary\",\n \"agent_id\": \"agent_01h455vb4pex5vsknk084sn02q\",\n \"environment_id\": \"env_01h455vb4pex5vsknk084sn02q\",\n \"policy\": {\n \"type\": \"cron\",\n \"expression\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\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.moonshot.cn/v1/triggers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Daily summary\",\n \"agent_id\": \"agent_01h455vb4pex5vsknk084sn02q\",\n \"environment_id\": \"env_01h455vb4pex5vsknk084sn02q\",\n \"policy\": {\n \"type\": \"cron\",\n \"expression\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/triggers")
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 \"name\": \"Daily summary\",\n \"agent_id\": \"agent_01h455vb4pex5vsknk084sn02q\",\n \"environment_id\": \"env_01h455vb4pex5vsknk084sn02q\",\n \"policy\": {\n \"type\": \"cron\",\n \"expression\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "trig_01h455vb4pex5vsknk084sn02q",
"name": "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:00.000Z",
"updated_at": "2026-08-01T09:00:00.000Z"
}{
"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>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}创建一个处于活跃状态的触发器,为智能体启动会话。
- cron 策略接受分钟粒度的五字段表达式和一个 IANA
timezone。实际触发会加入少量抖动。 - 智能体、环境、凭据库与记忆库引用在创建时校验。一个项目最多持有 200 个未归档的触发器。
- 每次触发向本次运行的会话投递
initial_events和一条平台上下文消息。
curl --request POST \
--url https://api.moonshot.cn/v1/triggers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Daily summary",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"policy": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "UTC"
}
}
'import requests
url = "https://api.moonshot.cn/v1/triggers"
payload = {
"name": "Daily summary",
"agent_id": "agent_01h455vb4pex5vsknk084sn02q",
"environment_id": "env_01h455vb4pex5vsknk084sn02q",
"policy": {
"type": "cron",
"expression": "0 9 * * *",
"timezone": "UTC"
}
}
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({
name: 'Daily summary',
agent_id: 'agent_01h455vb4pex5vsknk084sn02q',
environment_id: 'env_01h455vb4pex5vsknk084sn02q',
policy: {type: 'cron', expression: '0 9 * * *', timezone: 'UTC'}
})
};
fetch('https://api.moonshot.cn/v1/triggers', 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",
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([
'name' => 'Daily summary',
'agent_id' => 'agent_01h455vb4pex5vsknk084sn02q',
'environment_id' => 'env_01h455vb4pex5vsknk084sn02q',
'policy' => [
'type' => 'cron',
'expression' => '0 9 * * *',
'timezone' => 'UTC'
]
]),
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"
payload := strings.NewReader("{\n \"name\": \"Daily summary\",\n \"agent_id\": \"agent_01h455vb4pex5vsknk084sn02q\",\n \"environment_id\": \"env_01h455vb4pex5vsknk084sn02q\",\n \"policy\": {\n \"type\": \"cron\",\n \"expression\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\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.moonshot.cn/v1/triggers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Daily summary\",\n \"agent_id\": \"agent_01h455vb4pex5vsknk084sn02q\",\n \"environment_id\": \"env_01h455vb4pex5vsknk084sn02q\",\n \"policy\": {\n \"type\": \"cron\",\n \"expression\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/triggers")
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 \"name\": \"Daily summary\",\n \"agent_id\": \"agent_01h455vb4pex5vsknk084sn02q\",\n \"environment_id\": \"env_01h455vb4pex5vsknk084sn02q\",\n \"policy\": {\n \"type\": \"cron\",\n \"expression\": \"0 9 * * *\",\n \"timezone\": \"UTC\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "trig_01h455vb4pex5vsknk084sn02q",
"name": "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:00.000Z",
"updated_at": "2026-08-01T09:00:00.000Z"
}{
"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>"
}
}{
"error": {
"type": "invalid_parameter_error",
"message": "<string>",
"param": "<string>",
"request_id": "<string>"
}
}请求头
可选的幂等键。相同的键与请求体会在 24 小时内重放首个响应;以不同的请求体复用,或在首个请求仍在处理时复用,返回 409。
请求体
创建触发器的请求体。
人类可读的触发器名称。
1 - 256每次运行启动的智能体。
1 - 128^agent_[0-9a-hjkmnp-tv-z]{26}$承载触发器所启动会话的环境。
1 - 128^env_[0-9a-hjkmnp-tv-z]{26}$决定触发器何时运行的策略。
Show child attributes
Show child attributes
精确的智能体版本("1"、"2"……)。省略时选择触发时刻的最新版本。
128绑定到触发器所启动会话的资源。
16作为资源绑定到会话的文件。
- 文件
- 凭据库
- 记忆库
Show child attributes
Show child attributes
每次运行时添加到目标会话的开场事件。
16发送用户消息。
- 用户消息
- 用户中断
Show child attributes
Show child attributes
每次触发器运行使用哪个会话。
new_session, reuse_session TriggerRun 通知的 webhook 配置。缺省则禁用投递。
Show child attributes
Show child attributes
响应
已创建的触发器(活跃状态)。
保存的规则,按计划或按需启动智能体。
触发器 ID。
^trig_[0-9a-hjkmnp-tv-z]{26}$人类可读的触发器名称。
当前生命周期状态。
active, paused, archived 每次运行启动的智能体。
^agent_[0-9a-hjkmnp-tv-z]{26}$每次触发器运行使用哪个会话。
new_session, reuse_session 决定触发器何时运行的策略。
Show child attributes
Show child attributes
可见性范围。
official, org, project, user 创建者的用户 ID。
创建时间戳。
最后更新时间戳。
触发器暂停的原因。处于活跃状态时不存在。
Show child attributes
Show child attributes
精确的智能体版本("1"、"2"……)。缺省时在触发时刻选择最新版本。
承载触发器所启动会话的环境。
^env_[0-9a-hjkmnp-tv-z]{26}$绑定到触发器所启动会话的资源。
作为资源绑定到会话的文件。
- 文件
- 凭据库
- 记忆库
Show child attributes
Show child attributes
每次运行时添加到目标会话的开场事件。
发送用户消息。
- 用户消息
- 用户中断
Show child attributes
Show child attributes
创建或最后更新此触发器的不可变配置的类型,目前为 dream_policy_version。平台管理的触发器(此字段已设置)拒绝更新、暂停、恢复与归档——其生命周期跟随所属资源。仍可手动运行。
该不可变配置的 ID,例如梦境策略版本 ID。
触发器上次触发的时间。
即将到来的运行时间的近似值(UTC,最多 5 个)。仅活跃的 cron 触发器存在。
归档时间戳。处于活跃或暂停状态时不存在。
TriggerRun 通知的 webhook 配置。缺省则禁用投递。
Show child attributes
Show child attributes
此页面对您有帮助吗?