Skip to main content
Rules let you set constraints on working days, hours, and shift sequences. Use rules to enforce labor regulations, contractual limits, and scheduling policies.

Rule Types

ConstraintDescription
COUNTERCount occurrences within a period (days worked, hours, shifts)
SEQUENCELimit consecutive occurrences (max days in a row)

Counter Rules

Count and limit occurrences within a planning period.

Working Days

Limit total working days:
{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "DAYS_WORKED",
      "min": 2,
      "max": 4
    }
  ]
}

Days Idle

Ensure minimum days off:
{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "DAYS_IDLE",
      "min": 1,
      "max": 2
    }
  ]
}

Weekends Idle

Guarantee free weekends:
{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "WEEKENDS_IDLE",
      "min": 1,
      "max": 2
    }
  ]
}
Requires weekend definition in options to specify what constitutes a weekend.

Shift Type Limits

Limit specific shift types using tags:
{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "SHIFT_TYPES_WORKED",
      "shifts": ["NIGHT"],
      "max": 3
    }
  ]
}

Counter Types

TypeDescription
DAYS_WORKEDTotal days with at least one shift
DAYS_IDLETotal days without any shift
WEEKENDS_WORKEDComplete weekends with work
WEEKENDS_IDLEComplete weekends without work
SHIFT_TYPES_WORKEDShifts matching specific tags
SHIFT_TYPES_HOURS_WORKEDHours worked on shifts matching specific tags
HOURS_WORKEDTotal hours across all shifts

Period Scoping

By default, rules apply to the entire planning period. Scope rules to specific periods:

Fixed Period

{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "SHIFT_TYPES_WORKED",
      "shifts": ["NIGHT"],
      "max": 3,
      "period": {
        "from": "2024-03-06T08:00:00",
        "to": "2024-03-10T17:00:00"
      }
    }
  ]
}

Rolling Window

Apply the rule as a sliding window:
{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "SHIFT_TYPES_WORKED",
      "shifts": ["NIGHT"],
      "max": 3,
      "period": {
        "duration": "P3D"
      }
    }
  ]
}
Use rolling windows for rules like “no more than 3 night shifts in any 7-day period.”

Sequence Rules

Limit consecutive occurrences without specifying a period window.

Consecutive Working Days

{
  "rules": [
    {
      "constraint": "SEQUENCE",
      "type": "DAYS_WORKED",
      "min": 2,
      "max": 4
    }
  ]
}
Employees work between 2 and 4 consecutive days before a day off.

Conditional Rules

Trigger a rule when another rule’s threshold is exceeded. Example: If 20+ hours of night shifts within 72 hours, then require 2 days idle:
{
  "rules": [
    {
      "constraint": "COUNTER",
      "type": "HOURS_WORKED",
      "period": {
        "duration": "PT72H"
      },
      "min": 20,
      "shifts": ["NIGHT"],
      "then": {
        "constraint": "SEQUENCE",
        "type": "DAYS_IDLE",
        "min": 2
      }
    }
  ]
}
Conditional rules can create complex constraints. Test thoroughly to avoid making problems infeasible.

Rule Properties

constraint
string
required
Rule type: COUNTER or SEQUENCE
type
string
required
What to count or sequence (see tables above)
min
integer
Minimum count or sequence length
max
integer
Maximum count or sequence length
shifts
array
Filter rule to specific shift tags
period
object
Time scope with from/to dates or rolling duration
then
Rule
Conditional rule triggered when this rule is exceeded

Common Rule Patterns

{
  "constraint": "COUNTER",
  "type": "HOURS_WORKED",
  "min": 32,
  "max": 40,
  "period": { "duration": "P7D" }
}
{
  "constraint": "SEQUENCE",
  "type": "DAYS_WORKED",
  "max": 5
}
{
  "constraint": "COUNTER",
  "type": "WEEKENDS_IDLE",
  "min": 2,
  "period": {
    "from": "2024-01-01",
    "to": "2024-01-31"
  }
}
{
  "constraint": "COUNTER",
  "type": "SHIFT_TYPES_WORKED",
  "shifts": ["NIGHT"],
  "max": 2,
  "period": { "duration": "P7D" }
}