# Schedules ## List worker schedules **get** `/api/workers/{workerId}/schedules` List scheduled tasks for a worker. ### Path Parameters - `workerId: string` ### Returns - `schedules: array of WorkerSchedule` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` - `workerId: string` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/schedules \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` #### Response ```json { "schedules": [ { "id": "id", "budget": "low", "input": "input", "nextRunAt": "2019-12-27T18:11:19.117Z", "type": "scheduled" } ], "workerId": "workerId" } ``` ## Create a worker schedule **post** `/api/workers/{workerId}/schedules` Schedule a worker instruction for a future or recurring run. ### Path Parameters - `workerId: string` ### Body Parameters - `input: string` - `when: object { date, type } or object { delayInSeconds, type } or object { cron, type } or object { intervalSeconds, type }` - `object { date, type }` - `date: string` - `type: "scheduled"` - `"scheduled"` - `object { delayInSeconds, type }` - `delayInSeconds: number` - `type: "delayed"` - `"delayed"` - `object { cron, type }` - `cron: string` - `type: "cron"` - `"cron"` - `object { intervalSeconds, type }` - `intervalSeconds: number` - `type: "interval"` - `"interval"` - `budget: optional "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` ### Returns - `WorkerSchedule = object { id, budget, input, 2 more } or object { id, budget, delayInSeconds, 3 more } or object { id, budget, cron, 3 more } or object { id, budget, input, 3 more }` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/schedules \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $HANDINGER_API_KEY" \ -d '{ "input": "x", "when": { "date": "2019-12-27T18:11:19.117Z", "type": "scheduled" } }' ``` #### Response ```json { "id": "id", "budget": "low", "input": "input", "nextRunAt": "2019-12-27T18:11:19.117Z", "type": "scheduled" } ``` ## Cancel a worker schedule **delete** `/api/workers/{workerId}/schedules/{scheduleId}` Cancel a scheduled task for a worker. ### Path Parameters - `workerId: string` - `scheduleId: string` ### Returns - `cancelled: boolean` ### Example ```http curl https://v3.handinger.com/api/workers/$WORKER_ID/schedules/$SCHEDULE_ID \ -X DELETE \ -H "Authorization: Bearer $HANDINGER_API_KEY" ``` #### Response ```json { "cancelled": true } ``` ## Domain Types ### Worker Schedule - `WorkerSchedule = object { id, budget, input, 2 more } or object { id, budget, delayInSeconds, 3 more } or object { id, budget, cron, 3 more } or object { id, budget, input, 3 more }` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` ### Schedule List Response - `ScheduleListResponse object { schedules, workerId }` - `schedules: array of WorkerSchedule` - `object { id, budget, input, 2 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `nextRunAt: string` - `type: "scheduled"` - `"scheduled"` - `object { id, budget, delayInSeconds, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `delayInSeconds: number` - `input: string` - `nextRunAt: string` - `type: "delayed"` - `"delayed"` - `object { id, budget, cron, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `cron: string` - `input: string` - `nextRunAt: string` - `type: "cron"` - `"cron"` - `object { id, budget, input, 3 more }` - `id: string` - `budget: "low" or "standard" or "high" or "unlimited"` - `"low"` - `"standard"` - `"high"` - `"unlimited"` - `input: string` - `intervalSeconds: number` - `nextRunAt: string` - `type: "interval"` - `"interval"` - `workerId: string` ### Schedule Cancel Response - `ScheduleCancelResponse object { cancelled }` - `cancelled: boolean`