---
title: Booking rules
summary: Rules of one branch — the step of the booking grid, the cleanup after a visit for masters, places and devices, who gets a visit booked on Any master, and whether and when clients get a confirmation and a reminder.
tools: [talemo_get_booking_rules, talemo_set_booking_rules, talemo_get_any_master]
related: [finding-times, visit-notices, resource-schedule, services-and-prices, ../kits/industry-words-and-defaults]
search: [booking interval, buffer after appointment, reminder time, any master, who gets a visit]
---

# Booking rules

Booking rules belong to one branch. They are in **Settings → Booking rules**, and
a branch that never set them uses the defaults below. When the Client booking kit is
installed, it writes the starting values by industry (see
[Industry words and defaults](../kits/industry-words-and-defaults.md)).

Rules do not include opening hours: time is opened by the schedules of resources (see
[Schedule of a resource](resource-schedule.md)).

## Booking step

**Booking step** is how often a visit may start: every 5, 10, 15, 20, 30 or 60
minutes. The default is 15. Times in the Calendar grid and in the finder go by it,
counted from midnight of the branch's time zone, and a visit cannot be booked at a
moment off the step.

## Cleanup after a visit

**Cleanup after a visit** is set separately for a master, a place and a device. A service has no cleanup of its own.
The default is none for all three.

Cleanup comes after the work. The next visit may start when the place is ready, and
the last hour before a resource stops working is not lost because of it, as the work
fits into open time and only the cleanup goes past its edge. The finder shows work
time and time with cleanup separately, and other visits wait for the cleanup. In
the price list a service shows its cleanup after a plus sign.

The screen hints what each is: for a master "usually right on to the next",
for a place the chair, table, couch or room, for a device the lamps and anything
that is wiped.

## Any master

When a client names no master and several are free at that time, the visit goes to
one of them by the rule of the branch. The rule is one for the booking page, the
online assistant, the staff assistant, the web and MCP: the finder picks the master,
not the screen.

- **Evenly** (the default) — first the master with fewer hours of visits in the week of
  the visit. The week runs from Monday to Sunday in the branch's time; visits that took
  place count, cancelled ones do not. So work is shared equally between the masters. Among
  equals, the one the visit fits closest to: no gap before the neighbouring visit or the
  edge of open time, and none after.
- **No gaps in the schedule** (`no_gaps`) — the visit goes where it fills a free window,
  and of such windows the narrower one is taken: schedules have fewer empty gaps and long
  windows stay for long services. Masters may end up with different numbers of visits;
  among equals, the master with fewer hours in the week of the visit goes first.
- **In order** (`in_order`) — first the master who is higher in the list of masters;
  when busy, the next one. The owner sets the order. A master not in the list comes after
  the named ones, by order of adding; a deactivated master drops out of the list and, back
  at work, stands last.

Two things stand above the rule: when the client names a master, the visit goes to that
master, and a client booked "as last time" stays with the master of her last visit (see
[Finding free time for a booking](finding-times.md)). A place and a device do not follow the
rule: of the free ones the less busy that day is taken, then by order of adding. A new rule
applies to new bookings; visits already booked stay with their masters. `talemo_get_any_master`
shows whose hours they are and who is first.

## Clients

Two rules decide what clients are sent about a visit (see
[Visit notices](visit-notices.md)):

- **Confirm the booking right away** — Yes or No. The default is Yes. The message
  goes to the client's main contact.
- **Remind before the visit** — how many hours before the visit the reminder
  goes. The default is 24, which is the day before. Changing the hours
  recalculates the reminders that are still waiting; one whose new time has already
  passed is not sent and is marked on the visit as "booked less than N hours before the
visit".

## Changing rules

Rules save one by one, and a change shows in the branch settings at once. With the
tool, `dry_run` shows the rules as they would be without saving them. A field that is
not in the request stays as it was, and cleanup is changed only for the ones
named — a master, a place or a device.

## Who can do it

Rules are seen by anyone who sees the business and changed by anyone who can change
the branch. A role limited to some branches changes only those branches. The hours of
masters in a week are data about people: they are seen by anyone who sees visits, and a
role limited to its own sees only the hours of its own master. The online assistant of
a client is not shown the hours. Without the Client booking kit rules are unavailable.

## Tools and refusals

- `talemo_get_booking_rules` shows the rules of a branch: the step of the booking grid in minutes (`step_minutes`), the cleanup after a visit for a master, a place and a device (by `role`), whether the client is told at once that the visit is booked (`confirm_on_booking`) and how many hours before a visit the reminder goes (`remind_before_hours`), who gets a visit booked on Any master (`any_master`: `evenly`, `no_gaps` or `in_order`) and the masters of the branch in work in the order of In order (`master_order`: `resource_id` and `name`). Rules never set show the defaults: a step of 15 minutes, no cleanup, confirming at once, a reminder 24 hours before, `evenly`.
- `talemo_set_booking_rules` changes them: the step is 5, 10, 15, 20, 30 or 60, cleanup is 0 to 120 minutes for each one named (`role`: `master`, `place` or `device`), `remind_before_hours` is 1 to 72, `any_master` is `evenly`, `no_gaps` or `in_order`, `master_order` is the `resource_id` of the masters of the branch in order, the first one highest: the ones named come first, the others follow as they stood. What is left out stays; cleanup changes only for the ones named.
- An unknown rule and a master named twice in the order are refused with `request.body_invalid` and `params.field` `any_master` or `master_order`; a resource in the order that is not a master of the branch in work, with `record.reference_missing` and `params.field` `master_order`.
- `talemo_get_any_master` shows a week from Monday to Sunday in the branch's time (`day` is a day of that week, today when left out): the rule, the masters in work with the minutes of visits that week (`minutes`) — the very count the finder uses — and `first`, who gets the next visit. `first` is empty with `no_gaps` and when several masters share the fewest hours: there the window decides, not the hours. A role limited to its own sees its own master only, and `first` is empty for it.
- The rules decide what clients are sent later, and nothing is sent by this call. New hours move the reminders already waiting, and one that would fall in the past is skipped.
- Cleanup comes after the work and holds the resource: the next visit waits for its end.
- `dry_run` shows the rules as they would be. The rules belong to one branch, so pass `branch_id` every time.
