> ## 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.

# Sync Task

> Sync scheduled tasks to the scheduler (internal API)

<Note>This is an **internal API** called by the Web layer via the `X-Internal-Secret` header. It is not publicly exposed.</Note>

After the Web layer creates, updates, or deletes a scheduled task, it uses this endpoint to sync the task to the APScheduler scheduler in the AI Backend.

<ParamField header="X-Internal-Secret" type="string" required>
  Internal API secret (environment variable `INTERNAL_API_SECRET`)
</ParamField>

<ParamField body="action" type="string" required>
  Action type: `add` | `remove` | `update`
</ParamField>

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

<ParamField body="task" type="object">
  Task data (required for `add` and `update` actions)

  <Expandable title="task">
    <ParamField body="id" type="string" required>Task ID</ParamField>
    <ParamField body="user_id" type="string" required>User ID</ParamField>
    <ParamField body="title" type="string" required>Task title</ParamField>
    <ParamField body="prompt" type="string" required>Task prompt</ParamField>
    <ParamField body="run_mode" type="string" default="require-confirmation">Run mode</ParamField>
    <ParamField body="repeat_type" type="string" default="no-repeat">Repeat type</ParamField>
    <ParamField body="scheduled_date" type="string">Scheduled date</ParamField>
    <ParamField body="scheduled_time" type="string" default="12:00">Scheduled time</ParamField>
    <ParamField body="timezone" type="string" default="UTC">Timezone</ParamField>
    <ParamField body="connector" type="string" default="my-browser">Connector</ParamField>
    <ParamField body="status" type="string" default="pending">Status</ParamField>
    <ParamField body="notification_config" type="object">Notification configuration `{ email, feishu, inApp }`</ParamField>
  </Expandable>
</ParamField>

<ResponseField name="success" type="boolean">Whether the operation succeeded</ResponseField>
<ResponseField name="action" type="string">The action that was performed</ResponseField>
<ResponseField name="task_id" type="string">Task 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": "Daily Email Digest",
        "prompt": "Check inbox and generate a summary of today'\''s emails",
        "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>
