# Schedules ## List worker schedules `$ handinger workers:schedules list` **get** `/api/workers/{workerId}/schedules` List scheduled tasks for a worker. ### Parameters - `--worker-id: string` Worker id returned by the create worker endpoint. ### Returns - `WorkerScheduleListResponse: object { schedules, workerId }` - `schedules: array of WorkerSchedule` - `scheduled: 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"` - `delayed: 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"` - `cron: 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"` - `interval: 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"` - `workerId: string` ### Example ```cli handinger workers:schedules list \ --api-key 'My API Key' \ --worker-id t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM ``` #### Response ```json { "schedules": [ { "id": "id", "budget": "low", "input": "input", "nextRunAt": "2019-12-27T18:11:19.117Z", "type": "scheduled" } ], "workerId": "workerId" } ``` ## Create a worker schedule `$ handinger workers:schedules create` **post** `/api/workers/{workerId}/schedules` Schedule a worker instruction for a future or recurring run. ### Parameters - `--worker-id: string` Worker id returned by the create worker endpoint. - `--input: string` - `--when: object { date, type } or object { delayInSeconds, type } or object { cron, type } or object { intervalSeconds, type }` - `--budget: optional "low" or "standard" or "high" or "unlimited"` ### Returns - `worker_schedule: 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 }` - `scheduled: 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"` - `delayed: 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"` - `cron: 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"` - `interval: 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"` ### Example ```cli handinger workers:schedules create \ --api-key 'My API Key' \ --worker-id t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM \ --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 `$ handinger workers:schedules cancel` **delete** `/api/workers/{workerId}/schedules/{scheduleId}` Cancel a scheduled task for a worker. ### Parameters - `--worker-id: string` Worker id returned by the create worker endpoint. - `--schedule-id: string` Scheduled task id returned by the create schedule endpoint. ### Returns - `WorkerScheduleCancelResponse: object { cancelled }` - `cancelled: boolean` ### Example ```cli handinger workers:schedules cancel \ --api-key 'My API Key' \ --worker-id t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM \ --schedule-id sch_01HZY31W2SZJ8MJ2FQTR3M1K9D ``` #### Response ```json { "cancelled": true } ``` ## Domain Types ### Worker Schedule - `worker_schedule: 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 }` - `scheduled: 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"` - `delayed: 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"` - `cron: 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"` - `interval: 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"`