> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeus.agentspro.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 同步任务

> 同步定时任务到调度器（内部 API）

<Note>这是**内部 API**，由 Web 端通过 `X-Internal-Secret` header 调用，不对外暴露。</Note>

Web 端创建/更新/删除定时任务后，通过此接口将任务同步到 AI Backend 的 APScheduler 调度器。

<ParamField header="X-Internal-Secret" type="string" required>
  内部 API 密钥（环境变量 `INTERNAL_API_SECRET`）
</ParamField>

<ParamField body="action" type="string" required>
  操作类型：`add` | `remove` | `update`
</ParamField>

<ParamField body="task_id" type="string" required>
  任务 ID
</ParamField>

<ParamField body="task" type="object">
  任务数据（`add` 和 `update` 时必填）

  <Expandable title="task">
    <ParamField body="id" type="string" required>任务 ID</ParamField>
    <ParamField body="user_id" type="string" required>用户 ID</ParamField>
    <ParamField body="title" type="string" required>任务标题</ParamField>
    <ParamField body="prompt" type="string" required>任务提示词</ParamField>
    <ParamField body="run_mode" type="string" default="require-confirmation">运行模式</ParamField>
    <ParamField body="repeat_type" type="string" default="no-repeat">重复类型</ParamField>
    <ParamField body="scheduled_date" type="string">计划日期</ParamField>
    <ParamField body="scheduled_time" type="string" default="12:00">计划时间</ParamField>
    <ParamField body="timezone" type="string" default="UTC">时区</ParamField>
    <ParamField body="connector" type="string" default="my-browser">连接器</ParamField>
    <ParamField body="status" type="string" default="pending">状态</ParamField>
    <ParamField body="notification_config" type="object">通知配置 `{ email, feishu, inApp }`</ParamField>
  </Expandable>
</ParamField>

<ResponseField name="success" type="boolean">操作是否成功</ResponseField>
<ResponseField name="action" type="string">执行的操作</ResponseField>
<ResponseField name="task_id" type="string">任务 ID</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://zeus-api.agentspro.cn/scheduled-task/sync \
    --header 'X-Internal-Secret: your-secret' \
    --header 'Content-Type: application/json' \
    --data '{
      "action": "add",
      "task_id": "task_123",
      "task": {
        "id": "task_123",
        "user_id": "user_456",
        "title": "每日邮件摘要",
        "prompt": "检查收件箱并生成今日邮件摘要",
        "repeat_type": "daily",
        "scheduled_time": "09:00",
        "timezone": "Asia/Shanghai"
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "action": "add",
    "task_id": "task_123"
  }
  ```
</ResponseExample>
