Skip to content
Get started

Create a worker schedule

workers.schedules.create(strworker_id, ScheduleCreateParams**kwargs) -> WorkerSchedule
POST/api/workers/{workerId}/schedules

Schedule a worker instruction for a future or recurring run.

ParametersExpand Collapse
worker_id: str
input: str
minLength1
when: When
One of the following:
class WhenUnionMember0:
date: Union[str, datetime]
formatdate-time
type: Literal["scheduled"]
class WhenUnionMember1:
delay_in_seconds: int
minimum1
maximum31536000
type: Literal["delayed"]
class WhenUnionMember2:
cron: str
minLength1
type: Literal["cron"]
class WhenUnionMember3:
interval_seconds: int
minimum1
maximum31536000
type: Literal["interval"]
budget: Optional[Literal["low", "standard", "high", "unlimited"]]
One of the following:
"low"
"standard"
"high"
"unlimited"
ReturnsExpand Collapse
One of the following:
class UnionMember0:
id: str
budget: Literal["low", "standard", "high", "unlimited"]
One of the following:
"low"
"standard"
"high"
"unlimited"
input: str
next_run_at: datetime
formatdate-time
type: Literal["scheduled"]
class UnionMember1:
id: str
budget: Literal["low", "standard", "high", "unlimited"]
One of the following:
"low"
"standard"
"high"
"unlimited"
delay_in_seconds: int
input: str
next_run_at: datetime
formatdate-time
type: Literal["delayed"]
class UnionMember2:
id: str
budget: Literal["low", "standard", "high", "unlimited"]
One of the following:
"low"
"standard"
"high"
"unlimited"
cron: str
input: str
next_run_at: datetime
formatdate-time
type: Literal["cron"]
class UnionMember3:
id: str
budget: Literal["low", "standard", "high", "unlimited"]
One of the following:
"low"
"standard"
"high"
"unlimited"
input: str
interval_seconds: int
next_run_at: datetime
formatdate-time
type: Literal["interval"]

Create a worker schedule

import os
from datetime import datetime
from handinger import Handinger

client = Handinger(
    api_key=os.environ.get("HANDINGER_API_KEY"),  # This is the default and can be omitted
)
worker_schedule = client.workers.schedules.create(
    worker_id="t_org_123_w_01HZY2ZJQ8G7K42W2D7WF6V4GM",
    input="x",
    when={
        "date": datetime.fromisoformat("2019-12-27T18:11:19.117"),
        "type": "scheduled",
    },
)
print(worker_schedule)
{
  "id": "id",
  "budget": "low",
  "input": "input",
  "nextRunAt": "2019-12-27T18:11:19.117Z",
  "type": "scheduled"
}
Returns Examples
{
  "id": "id",
  "budget": "low",
  "input": "input",
  "nextRunAt": "2019-12-27T18:11:19.117Z",
  "type": "scheduled"
}