Learn how to define references to periods of time in the roster.
Many aspects that should be taken into consideration in producing a roster are only applicable during certain periods of time. For example, think of weekly limits for work, or the availability of employees during certain days of the week.
Specifying such periods of time is done using the periods field. This page explains how to configure this field for different use cases.
List of periods in the schedule. Periods can either be defined explicitly using custom definitions, or through a recurrent definition. A recurrent definition can be used to easily generate a list of similar periods (such as weeks, months, etc.).
List of days in the schedule. Each day will become one period. By default, each period will last the entire day. If a startTime and/or endTime are specified, these will apply to each period.
If true, the startTime and endTime will be applied to each individual day in the period. If false, the startTime will apply to the first day and the endTime will apply to the last day. Default: false.
The number of days between the start of each period. If not specified, this defaults to the value of daysPerPeriod, creating non-overlapping consecutive periods. Setting daysBetweenStarts to 1 will create a sliding window of periods.
If true, the startTime and endTime will be applied to each individual day in the period. If false, the startTime will apply to the first day and the endTime will apply to the last day. Default: false.
The most basic way to define periods is to refer to specific days in the roster. This is done by using the days field in the periods object.Within this object, you can specify specific days using dates (in CALENDAR payloads) or dayIndices (in RECURRING payloads).
Alternatively, you can specify the days of the week using daysOfWeek. For example, the following periods definition will refer to all Wednesdays and Fridays in the roster.
Finally, you can add a startTime and endTime to the days object to specify a time interval during the day. For example, the following periods definition will refer to all evenings on Wednesdays and Fridays.
This could be useful for instance to specify that an employee is not available for work during these times (though they are still available for work earlier in these days).
Referring to specific days using days of week and time interval
Creating periods through days will always consider each day in the roster as a
separate period. This is relevant on some constraints where the targets of the
constraint are applied to each period separately.
If you need to create periods consisting of multiple days, you can use the customDefinitions field in the periods object. These are defined through a start and end day (and optionally a start and end time).
For example, the following periods definition will refer to the period from January 1st to January 5th and the period from February 10th to February 14th.
Referring to a custom period using start and end days
Similarly to the days field, you can also add a startTime and endTime to the customDefinitions object to specify a time interval during the day.
For example, the following periods definition will refer to the period from 10:00 on January 1st to 18:00 on January 5th.
Referring to a custom period using start and end days and time interval
Finally, custom period definitions allow you to choose whether the start and end time should apply to each day individually.
For example, the following periods definition will refer to all periods of time between 20:00 and 06:00 on every day between January 1st and January 31st.
Referring to a custom period using start and end days and time interval and applying time to all days
If you want to create periods that are all the same length, the recurrentDefinition field might suit your needs. For example, if you want to create a constraint that applies on a weekly basis, the recurrent definition allows you to
easily specify this without having to define each week by its exact start and end days.For example, the following recurrent definition will create a non-overlapping set of periods that are each 7 days long, starting from the first day and continuing until the last day of the roster.
Defining weekly periods using a recurrent definition
If you only need your recurrent definition to create periods for a certain range within your roster, you can also specify the startDay and endDay properties.
For example, the following recurrent definition will create a non-overlapping set of periods that are each 7 days long, starting from April 1st and continuing until June 30th.
By default, periods created through a recurrent definition will be non-overlapping and consecutive. If you want to create a sliding window of periods, you can use the
daysBetweenStarts property. For example, we could use the following periods on a constraint to make sure that an employee never works more than 40 hours in any 7-day period.
Recurrent definitions allow for the use of start and end time similarly to custom definitions. This example shows a recurrent definition for weekend periods that start Friday afternoon and last until Sunday night.
Defining weekend periods with a start and end time
{ "periods": { "recurrentDefinition": { "startDay": { "date": "2026-01-02" // Start on the first Friday of the roster }, "daysPerPeriod": 3, // Periods last Friday-Sunday "daysBetweenStarts": 7, "startTime": "18:00", // Starts at 6pm on Friday "endTime": "22:00" // Ends at 10pm on Sunday } }}
If there are periods that are useful in multiple constraints, you can define them in the labels property of the configuration.
This can greatly reduce the size of your payloads when handled properly, and it can be smart to identify which periods are applicable for this within your integration.
Some commonly reused periods are for example weekends, weekdays, public
holidays and nights.
The below example shows how to define labels for weekends and then reuse them on an employee availability constraint to make it undesirable for employees to work on weekends.