Schedules API
Schedules provide org-scoped cron execution for saved scripts.
Endpoints
GET /api/scheduleslist schedules for the caller orgPOST /api/schedulescreate a scheduleGET /api/schedules/{id}fetch schedule detail and recent run historyPUT /api/schedules/{id}update schedule fieldsDELETE /api/schedules/{id}soft-disable by default (?hard=trueto hard-delete)POST /api/schedules/executeexecute due schedules for the authenticated org contextGET|POST /api/cron/scheduled-runsexecute due schedules with cron secret auth
Create payload fields
name,scriptId,agentId,cronExpressionare required.- Optional controls:
timezoneenabledvariablesvaultKeysmaxRuntimeMinutesmaxRetriesretryDelaySecondsconcurrencyLimitidempotencyWindowMinutes
Cron and payload constraints are validated with Zod plus cron-parser checks.
Runtime notes:
maxRuntimeMinutesdefaults to720(12 hours)maxRuntimeMinutessupports values up to1320(22 hours)
Execute request
POST /api/schedules/execute body:
{ "dryRun": false, "force": false, "limit": 10, "scheduleId": null}Constraints:
limit:1..100force: truerequiresscheduleId
Security and access
- Session auth and API key auth are both supported.
- Viewer role is read-only; create/update/delete/execute return 403.
- Script and agent ownership are validated against organization scope before writes.
Reliability guards
Execution enforces:
- global advisory lock for due-schedule scans plus per-schedule locks for individual execution
- schedule concurrency limit
- idempotency window checks
- billing gate (
canLaunchRuns) - agent readiness checks with auto-start for stopped/offline agents
- vault secret resolution before dispatch
Use together with /api/cron/stale-jobs to recover timed-out work and keep schedules healthy.