Constraints

You can set up general constraints for availability, a typical use-case is opening hours.

Availability-constraints are Timekit's way of defining general rules for availability. As mentioned, opening-hours are a kind of general availability-rule. Timekit defines two different kinds of constraints: "blocking" and "allowing". "Allowing" constraints implicitly blocks everything else, so for instance the constraint "allow_day", with the day set to Monday, will block all the other days in the week. This means that you do not need to explicitly block periods that are implicitly being blocked with an "allowing" constraint.

Resource constraints and general constraints

Timekit offers two places to define availability-constraints:

  1. On the resource, which could be defining working hours or vacation, constraints that are relevant only for that resource.
  2. On the request to the /availability endpoint (can also be pre-configured through projects), which could be defining a store's opening hours, constraints that are relevant across resources.

Constraints and timezones

Regardless of whether you're using resource availability-constraints or general availability-constraints, they will be calculated according to each resource's timezone. This means that if you set a general availability-constraint in a request to the /availability endpoint like this:

curl --request POST \
  --url https://api.timekit.io/v2/availability \
  --header 'Content-Type: application/json' \
  --user :live_api_key_7nzvc7wsBQQISLeFSVhROys9V1bUJ1z7 \
  --data '{
    "mode": "roundrobin_random",
    "output_timezone": "America/New_York",
    "resources": [
    	"7c0b9428-41f3-42cc-8ac4-f86c824eaa1f",
    	"e865df2c-3225-44f3-bb82-7c2e7ce6b360"
    ],
    "constraints": [
    	{"allow_hours": {"start": 9, "end": 17}},
      {"block_weekends": {} }
    ]
    "length": "2 hours",
    "from": "now",
    "to": "1 week"
  }'

And the two resources have different timezones, let's say America/Los_Angeles and America/New_York, the latest time-slot produced will end at 8pm, because 5pm L.A. time is 8pm New York time, and we specify that we want the output in New York time.

For a complete reference of availability-constraints, please refer to the API documentation.

More settings

Timekit supports a range of other settings, but they are out of scope of an introduction. For a complete list of settings please refer to our API reference.