Skip to content

Schedules API

Manage scheduled tasks and cron jobs.

Endpoints

MethodEndpointDescription
GET/api/agents/{id}/schedulesList schedules
POST/api/agents/{id}/schedulesCreate schedule
GET/api/agents/{id}/schedules/{scheduleId}Get schedule
PUT/api/agents/{id}/schedules/{scheduleId}Update schedule
DELETE/api/agents/{id}/schedules/{scheduleId}Delete schedule

List Schedules

bash
GET /api/agents/{id}/schedules

Query Parameters

ParameterTypeDescription
statusstringFilter by status (active, paused)
typestringFilter by type (once, delayed, cron)

Response

json
{
  "schedules": [
    {
      "id": "schedule-123",
      "name": "Daily Report",
      "type": "cron",
      "cron_expression": "0 9 * * *",
      "next_run": "2024-12-16T09:00:00Z",
      "last_run": "2024-12-15T09:00:00Z",
      "callback_type": "workflow",
      "callback_id": "workflow-456",
      "status": "active"
    }
  ]
}

Create Schedule

bash
POST /api/agents/{id}/schedules
Content-Type: application/json

Cron Schedule

json
{
  "name": "Daily Report",
  "type": "cron",
  "cron_expression": "0 9 * * *",
  "callback_type": "workflow",
  "callback_id": "workflow-456",
  "status": "active"
}

One-Time Schedule

json
{
  "name": "Send Reminder",
  "type": "once",
  "next_run": "2024-12-20T15:00:00Z",
  "callback_type": "workflow",
  "callback_id": "workflow-789"
}

Delayed Schedule

json
{
  "name": "Follow-up",
  "type": "delayed",
  "delay_seconds": 3600,
  "callback_type": "workflow",
  "callback_id": "workflow-123"
}

Response

json
{
  "id": "schedule-123",
  "name": "Daily Report",
  "type": "cron",
  "cron_expression": "0 9 * * *",
  "next_run": "2024-12-16T09:00:00Z",
  "status": "active",
  "created_at": "2024-12-15T10:00:00Z"
}

Get Schedule

bash
GET /api/agents/{id}/schedules/{scheduleId}

Response

json
{
  "id": "schedule-123",
  "name": "Daily Report",
  "type": "cron",
  "cron_expression": "0 9 * * *",
  "next_run": "2024-12-16T09:00:00Z",
  "last_run": "2024-12-15T09:00:00Z",
  "callback_type": "workflow",
  "callback_id": "workflow-456",
  "status": "active",
  "executions": [
    {
      "id": "exec-1",
      "executed_at": "2024-12-15T09:00:00Z",
      "status": "success"
    }
  ]
}

Update Schedule

bash
PUT /api/agents/{id}/schedules/{scheduleId}
Content-Type: application/json

Request Body

json
{
  "name": "Updated Schedule",
  "cron_expression": "0 10 * * *",
  "status": "paused"
}

Delete Schedule

bash
DELETE /api/agents/{id}/schedules/{scheduleId}

Schedule Types

TypeDescription
onceExecute at specific time
delayedExecute after delay
cronRecurring with cron expression

Schedule Status

StatusDescription
activeSchedule is running
pausedTemporarily disabled
completedOne-time schedule finished

Cron Expressions

ExpressionDescription
* * * * *Every minute
0 * * * *Every hour
0 9 * * *Daily at 9 AM
0 9 * * 1Monday at 9 AM
0 9 1 * *First of month at 9 AM

Errors

CodeDescription
400Invalid schedule data
404Schedule not found

Examples

Create Hourly Schedule

bash
curl -X POST .../schedules \
  -d '{
    "name": "Hourly Sync",
    "type": "cron",
    "cron_expression": "0 * * * *",
    "callback_type": "workflow",
    "callback_id": "sync-workflow"
  }'

Pause Schedule

bash
curl -X PUT .../schedules/schedule-123 \
  -d '{"status": "paused"}'

Released under the MIT License.