Scheduler API

API endpoints for creating and managing scheduled tasks. Supports interval, daily and weekly triggers, all persisted and executed by the agent.

Task Types

Three trigger types are supported. config holds the type-specific fields.

interval  {"minutes": 60}                      run every 60 minutes
daily     {"hour": 9, "minute": 0}             run daily at 09:00
weekly    {"weekdays": [0, 2], "hour": 9, "minute": 0}  run Mon & Wed at 09:00

weekday values: 0=Monday … 6=Sunday

Create Task

Create Task

POST /api/scheduler
Content-Type: application/json

{
  "name": "Daily weather report",
  "task_type": "daily",
  "prompt": "Check today's weather in Beijing and report it",
  "config": { "hour": 8, "minute": 30 },
  "enabled": true,
  "session_id": null
}

Response: {
  "success": true,
  "task": { "id": "task_xxx", "name": "Daily weather report", "type": "daily", "enabled": true }
}

Manage Tasks

List Tasks

GET /api/scheduler
Response: { "success": true, "tasks": [ ... ] }

Get Task

GET /api/scheduler/{task_id}
Response: { "success": true, "task": { ... } }

Update Task

PUT /api/scheduler/{task_id}
Body: { "name": "...", "prompt": "...", "config": { ... }, "enabled": true }
Response: { "success": true, "task": { ... } }

Delete Task

DELETE /api/scheduler/{task_id}
Response: { "success": true }

Toggle Task

PATCH /api/scheduler/{task_id}/toggle
Response: { "success": true, "enabled": false }

Scheduler Stats

Task Stats

GET /api/scheduler/stats
Response: {
  "success": true,
  "stats": { "total": 5, "enabled": 3, "running": 0, "failed": 1 }
}

Execution History

GET /api/scheduler/history/list?limit=20
Response: { "success": true, "history": [ { "task_id": "...", "status": "success", "started_at": "..." } ] }

Natural Language Scheduling

You can also ask the agent in plain language to create a task; it calls the scheduler tool directly.