Schedules API
Manage scheduled tasks and cron jobs.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/agents/{id}/schedules | List schedules |
| POST | /api/agents/{id}/schedules | Create 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}/schedulesQuery Parameters
| Parameter | Type | Description |
|---|---|---|
status | string | Filter by status (active, paused) |
type | string | Filter 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/jsonCron 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/jsonRequest Body
json
{
"name": "Updated Schedule",
"cron_expression": "0 10 * * *",
"status": "paused"
}Delete Schedule
bash
DELETE /api/agents/{id}/schedules/{scheduleId}Schedule Types
| Type | Description |
|---|---|
once | Execute at specific time |
delayed | Execute after delay |
cron | Recurring with cron expression |
Schedule Status
| Status | Description |
|---|---|
active | Schedule is running |
paused | Temporarily disabled |
completed | One-time schedule finished |
Cron Expressions
| Expression | Description |
|---|---|
* * * * * | Every minute |
0 * * * * | Every hour |
0 9 * * * | Daily at 9 AM |
0 9 * * 1 | Monday at 9 AM |
0 9 1 * * | First of month at 9 AM |
Errors
| Code | Description |
|---|---|
| 400 | Invalid schedule data |
| 404 | Schedule 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"}'