🎉 Cmdop v1.0 is here! Download now →
Skip to Content

Schedules API

Create and manage scheduled tasks.

List Schedules

GET /schedules

Query Parameters

ParameterTypeDescription
machine_idstringFilter by machine
enabledbooleanFilter by status
limitnumberResults per page
offsetnumberPagination offset

Response

{ "data": [ { "id": "sched_abc123", "name": "Daily Backup", "machine_id": "mach_xyz789", "command": "pg_dump mydb > /backup/db.sql", "cron": "0 3 * * *", "enabled": true, "timezone": "UTC", "next_run": "2024-01-21T03:00:00Z", "last_run": { "at": "2024-01-20T03:00:00Z", "exit_code": 0, "duration": 15000 }, "created_at": "2024-01-15T10:30:00Z" } ], "meta": { "total": 10, "limit": 20, "offset": 0 } }

Get Schedule

GET /schedules/:id

Response

{ "data": { "id": "sched_abc123", "name": "Daily Backup", "description": "Backup production database every night", "machine_id": "mach_xyz789", "command": "pg_dump mydb > /backup/db.sql", "cron": "0 3 * * *", "enabled": true, "timezone": "UTC", "timeout": 300000, "notify": { "on_success": false, "on_failure": true }, "next_run": "2024-01-21T03:00:00Z", "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-18T14:20:00Z" } }

Create Schedule

POST /schedules

Request Body

FieldTypeRequiredDescription
namestringYesSchedule name
machine_idstringYesTarget machine
commandstringYesCommand to run
cronstringYesCron expression
enabledbooleanNoDefault: true
timezonestringNoDefault: UTC
timeoutnumberNoTimeout in ms
notifyobjectNoNotification settings

Example

curl -X POST https://api.cmdop.com/v1/schedules \ -H "Authorization: Bearer TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Daily Backup", "machine_id": "mach_xyz789", "command": "pg_dump mydb > /backup/db.sql", "cron": "0 3 * * *", "timezone": "America/New_York", "notify": { "on_failure": true } }'

Update Schedule

PATCH /schedules/:id

Request Body

{ "name": "Updated Name", "cron": "0 4 * * *", "enabled": false }

Delete Schedule

DELETE /schedules/:id

Response

{ "data": { "deleted": true } }

Run Now

Trigger schedule immediately:

POST /schedules/:id/run

Response

{ "data": { "command_id": "cmd_xyz789", "status": "running" } }

Schedule History

GET /schedules/:id/history

Query Parameters

ParameterTypeDescription
sincestringISO timestamp
limitnumberResults per page

Response

{ "data": [ { "id": "run_abc123", "started_at": "2024-01-20T03:00:00Z", "finished_at": "2024-01-20T03:00:15Z", "exit_code": 0, "duration": 15000, "stdout": "...", "stderr": "" } ], "meta": { "total": 30, "limit": 20, "offset": 0 } }

Schedules API | Cmdop