Use constraints to set general rules for availability.

📘

Formerly known as "filters"

In our previous availability endpoint POST /findtime, constraints were known as "filters". We've renamed them to "constraints", but they serve the same purpose.

The most typical use-case for constraints is setting opening hours and/or working hours. You can do this with two different kinds of constraints; blocking and allowing. "Allowing" constraints implicitly blocks everything else, so for instance the constraint AllowDay, 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. So if you are using the allow_weekdays constraint, you don't need to also supply the block_weekends constraint.

You can combine constraints to fit your use-case. As mentioned the most common use case is setting opening hours. With opening hours Monday to Friday 9am to 5pm this would look like this:

"constraints": [
  {"block_weekends": {} },
  {"allow_hours": {"start": 9, "end": 17} }
]

If you are closed for an hour during lunch, you could add a "blocking" contstraint:

"constraints": [
  {"block_weekends": {} },
  {"allow_hours": {"start": 9, "end": 17} },
  {"block_hours": {"start": 12, "end": 13} }
]

You can set constraints for your resources (eg. individual working hours in their specific timezone) and your projects (eg. business opening hours). You can also add constraints on the fly when you perform your availability queries. All of these different constraints will be taken into account by Timekit when looking for availability.

Available constraints

Day and time

Allow or block certain hours on a specific day of the week.

// Allow Mondays from 9am-5pm
"constraints": [
  {"allow_day_and_time": {"day": "Monday", "start": 9, "end": 17} },
]

// Block the day and time instead
"constraints": [
  {"block_day_and_time": {"day": "Monday", "start": 9, "end": 17} },
]

Hours

Allow or block certain hours of the day.

// Opening hours with lunch break
"constraints": [
  {"allow_hours": {"start": 9, "end": 17} },
  {"block_hours": {"start": 12, "end": 13} }
]

Day

Allow or block a specific day.

// Allow Mondays
"constraints": [
  {"allow_day": {"day": "Monday"} },
]

// Block the day instead
"constraints": [
  {"block_day": {"day": "Monday"} },
]

Period

Allow or block a specific time period given two timestamps.
Ideal for blocking out a fixed timerange like holidays (if it's not practical to block out the time using calendar events instead)

// Allow from June 1st 9am to June 30th 5pm
"constraints": [
  {"allow_period": {"start": "2018-06-01 09:00:00", "end": "2018-06-30 17:00:00"} }
]

Weekends

Only allow or block weekends.

"constraints": [
  {"allow_weekends": {} }
]

"constraints": [
  {"block_weekends": {} }
]