---
metadata:
  - name: generator
    content: Diplodoc Platform v5.19.6
alternate:
  - https://docs.routeq.com/doc/en/vrp/properties-of-vehicles-rest-schedule.md
  - https://docs.routeq.com/doc/tr/vrp/properties-of-vehicles-rest-schedule.md
---
> **Documentation Index:** Fetch the complete configuration index at https://docs.routeq.com/doc/en/llms.txt


# Courier working mode

By default, the service plans a route only with stops that are necessary for cargo delivery. However, couriers often can't work without stopping: they need to have lunch breaks, and you must take these into account when you build routes. Moreover, on long-distance runs, drivers are required to make stops at certain intervals to meet the work and rest requirements.

## Breaks {#rest-schedule}

To control the couriers' working hours, use the `vehicle.rest_schedule.breaks` object. You can set simple or complex schemes to schedule breaks for rest, maintenance, or other activities.

* For couriers, use the `vehicles.rest_schedule.breaks` object.
* For shifts, use the `vehicles.shifts.N.rest_schedule.breaks` object. Shift-level breaks have priority over courier-level ones.

{% note info %}

Shift-level breaks aren't added to courier-level breaks but rather replace them.

{% endnote %}

You can specify a unique ID for each break:

* If you want to set a break at the courier level, specify the ID in the `rest_schedule.breaks.N.work_break_id` field on the **Vehicles** sheet.     
* If you want to set a break at the shift level, specify the ID in the `shifts.N.rest_schedule.breaks.N.work_break_id` field.

IDs specified for a single schedule `rest_schedule` must be unique and have the same format: string or numeric.

**Example 1**

A courier must deliver 10 orders in two shifts. There are no shift-level breaks. There is a one-hour courier-level break (`rest_duration_s` = 3600) after about an hour after the start of the shift (`from_start` = `01:00 - 01:30`).

As a result, the courier will have two breaks: one for each shift. The break in the first shift will start at 10:15 and the break in the second shift at 15:06.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/549b4a29-b91770f-73d962c9-dcff565) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/549b4a29-b91770f-73d962c9-dcff565) ⋅ [View on map](https://yandex.com/courier/mvrp-map#549b4a29-b91770f-73d962c9-dcff565)

**Example 2**

A courier must deliver 15 orders in two shifts. One half-hour break (`rest_duration_s` = 1800) in about two hours after the start of work is scheduled for each shift. There are no courier-level breaks. 

As a result, the courier will have two breaks: one for each shift. The break in the first shift will start at 11:36 and the break in the second shift at 16:30.  

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/d5a83866-e05a31f7-8cfc2f55-2430c8d2) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/d5a83866-e05a31f7-8cfc2f55-2430c8d2) ⋅ [View on map](https://yandex.com/courier/mvrp-map#d5a83866-e05a31f7-8cfc2f55-2430c8d2)

**Example 3**

The same conditions as in example 2, but there's an additional one-hour break set at the courier level approximately one hour after the start of the shift (`from_start` = `01:00 - 01:30`). As a result, breaks are set both at the shift level and at the courier level.

Consequently, only shift-level breaks at 11:07 and 16:17 are scheduled, as they have a higher priority over courier-level breaks and replace them.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/ca2f90d2-4a8b024c-f4c2db85-82603951) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/ca2f90d2-4a8b024c-f4c2db85-82603951) ⋅ [View on map](https://yandex.com/courier/mvrp-map#ca2f90d2-4a8b024c-f4c2db85-82603951)

### Break presets {#rest-schedule-presets}

You can set a courier's working hours using the parameter `vehicles.rest_schedule_preset`, which contains a set of settings you can use right away:

* The courier will take a 45-minute break no later than 4.5 hours of work.

* [Limits](https://docs.routeq.com/doc/en/vrp/properties-of-time-window.md#hard-and-soft-windows) will be applied to the shift duration (excluding breaks):

    * Soft: 9 hours.

    * Hard: 10 hours.

Possible values for the `rest_schedule_preset` parameter:

* `public_transport`: You can divide the break into multiple parts, each at least 10 minutes.

* `private_transport`: You can divide the break into two parts: 15 and 30 minutes.

* `multiday_private_transport`: The `private_transport` mode for multi-day routes. Besides regular breaks, you can also add:

    * Daily break: the last 11 hours of each weekday.
    * Weekly break: the last 45 hours of each week.

A route break will be divided into parts if the following conditions are met:

* There's not enough time between orders for a full break.

* There are waiting times between orders, where you can fit breaks.

You can also prohibit couriers from splitting breaks. To do this, use the option `can_split_preset_work_breaks` = `false` (by default it's `can_split_preset_work_breaks` = `true`).

**Example 1**

The courier has working hours `rest_schedule_preset` = `private_transport`. They contain a break that can be split into two parts. There's an interval between orders that a full break can fit into. As a result, a single break of 45 minutes is scheduled.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/51c774f7-5813184-a71ed958-9f54f91f) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/51c774f7-5813184-a71ed958-9f54f91f) ⋅ [View on map](https://yandex.com/courier/mvrp-map#51c774f7-5813184-a71ed958-9f54f91f)

**Example 2**

The courier has working hours `rest_schedule_preset` = `public_transport`. They contain a break that can be split into multiple parts. There's not enough time between orders for a full break. There's also a waiting time that can accommodate the part of the break. As a result, two breaks are scheduled: 21 and 23 minutes.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/27d7e58-5c45ed49-38429301-52d0258e) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/27d7e58-5c45ed49-38429301-52d0258e) ⋅ [View on map](https://yandex.com/courier/mvrp-map#27d7e58-5c45ed49-38429301-52d0258e)

**Example 3**

The courier has working hours `rest_schedule_preset` = `public_transport`. The courier has 14 orders. The shift duration has a hard restriction of 10 hours. As a result, one order remained undelivered because it would have required the courier to work more than 10 hours to deliver it.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/77e6f11f-7f2ac857-87d60078-e0917365) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/77e6f11f-7f2ac857-87d60078-e0917365) ⋅ [View on map](https://yandex.com/courier/mvrp-map#77e6f11f-7f2ac857-87d60078-e0917365)

**Example 4**

The courier has working hours `rest_schedule_preset` = `multiday_private_transport`. They have to deliver one order to a remote location. As a result, the courier delivers the order on the following day. They start at 8:00 and make three stops along the way:

- A 45-minute break after 4 hours and 30 minutes of travel.
- An 11-hour break from the end of the workday to 8:00 the next day.
- A 45-minute break after 4 hours and 30 minutes of travel.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/b915b33a-e424b983-5e238543-71c432d6) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/b915b33a-e424b983-5e238543-71c432d6) ⋅ [View on map](https://yandex.com/courier/mvrp-map#b915b33a-e424b983-5e238543-71c432d6)

### Schedule templates {#template-rest-shedule}

You can describe breaks for each courier separately or create templates for multiple couriers or for a shift. Moreover, you can combine individual and template schedules.

To create a template, add the `template_rest_schedules` parameter to `options` and specify an array of schedules in it: `[{"id": string, "breaks": [...]}]`.

To use a courier-level template, add the `rest_schedule_id` parameter to `vehicles` and specify the `id` of the schedule template from `options` in that parameter. To use a shift-level template, add the mentioned parameter to `vehicles.shifts.N`.

### Break duration {#rest-duration-s}

You can set the break duration using the `rest_duration_s` parameter mandatory for every break.

#|
||**Parameter** | **Value** | **Example**||
||`rest_duration_s` | Break duration in seconds. | `"rest_duration_s": 600`

The break should last 10 minutes (600 seconds).||
|#


### Break start conditions {#time-range-new}

The break start is indicated by a time range (from and to). If there are multiple breaks, each range specifies the working range after the end of the previous break. For example, if the first break is `04:00–05:00` and the second break is `02:00–03:00`, the first break must start between 4 and 5 hours after work starts, and the second break must start between 2 and 3 hours after the end of the first break.
 
You can set the conditions for starting a break in several ways, which are described below.

#|
||**Parameter** | **Value** | **Example**||
||`soft_time_range` | Soft time window for a break.<br><br>
The break may start earlier or later but with a [penalty](https://docs.routeq.com/doc/en/vrp/properties-of-time-window.md#hard-and-soft-windows) (`penalty`). | `soft_time_range` = `01:00:00-03:00:00`<br><br>
It's recommended to start the break no earlier than in 1 hour and no later than in 3 hours.||
||`hard_time_range` | Hard time window for a break.<br><br> 
The break must start [strictly at the scheduled time](https://docs.routeq.com/doc/en/vrp/properties-of-time-window.md#hard-and-soft-windows). A hard time window includes a soft time window. | `hard_time_range` =  `02:00:00-04:00:00`<br><br>
The break must start no earlier than in 2 hours and no later than in 4 hours.||
||`desired_work_duration` | Preferred time until break.<br><br> 
The break will start at the specified time if this doesn't increase the route's cost. Can be specified without indicating the `soft_time_range` and `hard_time_range` time windows. If the windows are set, the value of the `desired_work_duration` parameter should be within them.<br><br> 
The preferred time can be set in one of the following formats:<br><br> 
* Numerical (for example, `7200` seconds): Available only when planning via the API. 
* String (for example, `3:45:00`): Available when planning via the API and filling an Excel file. | `desired_work_duration` = `03:00:00`<br><br>
It's preferred that 3 hours pass before the break starts. ||
|#

{% note info %}

A soft `soft_time_range` and hard `hard_time_range` time windows are independent of each other and can be used separately.

{% endnote %}

**Example 1**

A courier is assigned to a route between Moscow and St. Petersburg with the first break after 4 hours (`hard_time_range` = `04:00:00-04:10:00`) and then with breaks every 2 hours (`hard_time_range` = `01:50:00-02:00:00`). As a result, the route has three scheduled breaks.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/d35e836a-dc466155-d582820a-8e86b846) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/d35e836a-dc466155-d582820a-8e86b846) ⋅ [View on map](https://yandex.com/courier/mvrp-map#d35e836a-dc466155-d582820a-8e86b846)

**Example 2**

Two couriers have two breaks scheduled in 2–3 hours after the last break (or start of work if this is the first break), `soft_time_range` = `02:00:00-03:00:00`:

- The first break lasts 20 minutes (`rest_duration_s` = 1200).
- The second break lasts 30 minutes (`rest_duration_s`= 1800).

The first courier finishes work earlier, so only one break is scheduled for them. The second courier works longer and gets two breaks.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/a7941c3-aaeb5258-c0427415-87679ab6) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/a7941c3-aaeb5258-c0427415-87679ab6) ⋅ [View on map](https://yandex.com/courier/mvrp-map#a7941c3-aaeb5258-c0427415-87679ab6)

### Break place {#time-range-rest-place}

For a courier to take a break at a specific location:

* In the `type` field on the **Orders** sheet, set the `rest_place` type for the location.
* In the `at_rest_place` field on the **Vehicles** sheet, set `true` for the break. 

#|
||**Parameter** | **Value** | **Example**||
||`at_rest_place` | An option to have a break in a location with the `rest_place` type. If this option is enabled, all breaks must either be at such locations or outside of them. | `at_rest_place` = `true`

All breaks will take place at locations with `type` = `rest_place`.||
|#

A unique location ID with the `rest_place` type is specified in the `id` field on the **Orders** sheet. Note that a location ID isn't a [break](#rest-schedule) ID. You can specify a unique break ID in the following fields on the **Vehicles** sheet:

* `rest_schedule.breaks.N.work_break_id`: If the break is set at the courier level.
* `shifts.N.rest_schedule.breaks.N.work_break_id`: If the break is set at the shift level.  

The courier can't visit break locations that are situated within the [geofences](#incompatible-geozones) that are restricted for them.

You can set run-specific requirements for visiting a break location with the `rest_place` type using the `incompatible_load_types` parameter (see [Order incompatibility](https://docs.routeq.com/doc/en/vrp/properties-of-orders.md#order-incompatibility)). For example, a courier is delivering an order with the `load_type` = `ice-cream` type, and the `rest_place` location's type is `load_type` = `no-refrigerator`. To restrict the courier from visiting this location for a break, set `ice-cream` as incompatible with `no-refrigerator` on the **Incompatible_load_types** sheet.

**Example**

Two couriers have 19 orders scheduled for them. The first courier should rest every 2–3 hours, and the second should rest every 3–4 hours. Both couriers have the same rest location specified for them: type `rest_place`.

The first courier starts the route at 7:00 and arrives at the rest location at 9:23, where they rest for 30 minutes before continuing. The second courier starts the route at 8:00 and manages to deliver all of their orders before 12 without stopping to rest.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/7429fe7d-a24e9536-7f7b1680-5240d922) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/7429fe7d-a24e9536-7f7b1680-5240d922) <!-- ⋅ [View on map](https://yandex.com/courier/mvrp-map#7429fe7d-a24e9536-7f7b1680-5240d922) -->


### Break types {#types-breaks}

Additional time intervals affect the start of the break that's set using time windows or the `desired_work_duration` parameter. For example, the courier should work for several hours before they can rest. To take additional time into account, specify the value of the `break_type` parameter.

#|
||**Value** | **Description** ||
||`from_start` | Working hours from the start of the route. Includes travel time, waiting time, and handling time for orders and depots.<br><br>
The break can't be repeated. The presence and duration of other breaks are not taken into account. ||
||`from_last` | Default value.<br><br>
Working hours from the last break (or from the start of the route if it's the first break). Includes travel time, waiting time, and handling time for orders and depots. ||
||`travel` | Travel time and waiting time from the start of the route. Handling time is not taken into account. ||
||`continuous` | Travel time and waiting time from the completion of the previous order. Handling time is not taken into account. ||
||`driving` | Travel time from the start of the route. Waiting time and handling time are not taken into account. ||
||`exact` | Break start time. The break can't be repeated.<br><br> 
The work start time. The presence and duration of other breaks are not take into account. The break won't start if the route ends before the break start time. ||
|#

{% note info %}

Make sure your `exact` breaks are specified in the correct order. For example, if you need to schedule two breaks (from 12:00 to 12:30 and from 10:00 to 10:30), they should be listed in the schedule in the following order:
 
- `exact` = `10:00 - 10:30`.
- `exact` = `12:00 - 12:30`.

{% endnote %}

You can set the `break_type` and `penalty` values in break schedule templates (`rest_schedule.break_type`, `rest_schedule.penalty`), as well as in the settings of each break (`rest_schedule.breaks.break_type`, `rest_schedule.breaks.penalty`).

If `break_type` is specified in the break schedule templates, then the `break_type` value in the settings of this break: 

* Must be the same.
* May be not specified. In this case, the settings from the schedule templates will apply to the break.

If `break_type` is not specified in the schedule templates, you can set different `break_type` values for different breaks in their settings.   

**Example** 

A courier needs to deliver 12 orders during the shift from 09:00 to 17:00. There are two breaks. 

The first break is scheduled from 11:00 to 12:00. It started two hours after the courier started his work, which corresponds to the hard time window `hard_time_range` = `1:30 – 3:30`. The first break is planned from the start of the shift.

The second break is scheduled after the first one from 13:30 to 14:30, which also fits within the restrictions of the hard time window, `hard_time_range` =  `1:00 - 2:00`. 

At the same time, the working interval between the first break and the second break matches the desired duration (`desired_work_duration` = `1:30`) and amounts to 1 hour and 30 minutes.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/da888306-e275541-a5bb96c9-658d0969) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/da888306-e275541-a5bb96c9-658d0969) ⋅ [View on map](https://yandex.com/courier/mvrp-map#da888306-e275541-a5bb96c9-658d0969)

#### **Order-related breaks** {#breaks-with-orders}

#|
|| **Parameter** | **Value** | **Example** ||
|| `before_first` | A break before the start of the first order. It is set in seconds. | `"before_first": 900`

The break before the first order lasts 15 minutes (900 seconds). ||
|| `after_last` | A break after completing the last order. It is set in seconds. | `"after_last": 1200`

The break after completing the last order lasts 20 minutes (1200 seconds). ||
|#

These break types are considered [`repeatable`](#repeatable). If you specify this type once, it will be automatically added to each run.

**Example** 

There's a route with two shifts planned: the morning and evening one. The courier's vehicle is an isothermal van. In the evenings, the courier delivers orders with temperature mode requirements.

The courier checks the temperature in the van twice a day. The following breaks are scheduled for the shifts:

- A 15-minute break before delivering the first order (`before_first` = 900).
- A lunch break after two hours of work (`from_start` = 02:00 - 02:15).
- A 15-minute break after the last order (`after_last` = 900).

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/3d1a55fe-1d6ff816-a50b7ca5-cb141270) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/3d1a55fe-1d6ff816-a50b7ca5-cb141270) ⋅ [View on map](https://yandex.com/courier/mvrp-map#3d1a55fe-1d6ff816-a50b7ca5-cb141270)

#### **Using different break types** {#different-types-breaks}

You can set different break types (`break_type`) in a single schedule. Other breaks and their duration don't affect the breaks scheduled from the start of the route (`from_start`) and at a specific time (`exact`).

**Example** 

A courier must deliver 11 orders. There are three breaks:

- The first one lasts 15 minutes and starts after two hours of work (`from_last` = `02:00 - 02:15`).
- The second one starts after four hours of work (`from_start` = `04:00 - 04:15`).
- The third one is a fixed break from 14:00 to 14:20 (`exact` = `14:00 - 14:20`).

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/83dacb6f-3abf13b7-93300378-ffc4b32b) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/83dacb6f-3abf13b7-93300378-ffc4b32b) ⋅ [View on map](https://yandex.com/courier/mvrp-map#83dacb6f-3abf13b7-93300378-ffc4b32b)

### Splitting breaks {#shared-rests}

You can split the break into smaller parts if needed. For example, if there's not enough time between orders for a full break. To do this, specify the parameter `can_be_split` = `true` in the `breaks` schedule.

You can also specify additional parameters for the split break:

#|
|| **Parameter** | **Value** | **Example** ||
|| `max_split_parts` | The parameter determines how many parts the break will be split into. By default, it's 2 parts. | `"max_split_parts": 5`

You can split the break into 5 parts. ||
|| `min_split_part_duration_s` | The minimum duration of a single part of the break. It is set in seconds. By default, it's 10 minutes. | `"min_split_part_duration_s": 1200`

You can split the break into parts with a minimum duration of 20 minutes (1200 seconds). ||
|| `min_first_split_part_duration_s` | The parameter specifies the minimum duration of the first part of the break. It is set in seconds. By default, this is 1/3 of the total break duration. | `"min_first_split_part_duration_s": 1800`

The first part of the break should be at least 30 minutes (1800 seconds). ||
|| `min_last_split_part_duration_s` | The parameter specifies the minimum duration of the final part of the break. It is set in seconds. By default, this is 2/3 of the total break duration. | `"min_last_split_part_duration_s": 2400`
 
The final part of the break should be at least 40 minutes (2400 seconds). ||
|#

The sum of the parts of a split break can exceed its total duration.

The maximum number of parts is specified in the `max_split_parts` parameter. Their duration must meet the conditions: 
* The first part is no less than `min_first_split_part_duration_s`.
* The last part is no less than `min_last_split_part_duration_s`.
* Each part is no less than `min_split_part_duration_s`.

When splitting, initial break time decreases. It may turn out that the remainder for allocating the last part of the break will be less than specified in `min_last_split_part_duration_s`. In this case, the minimum necessary value that's needed to comply with the `min_last_split_part_duration_s` restriction will be automatically added to it.

**Example 1**

A courier can go on one two-hour break: `rest_duration_s` = 7200. Several orders have narrow time windows, so you can fill the waiting time between them with breaks. Since there isn't enough time between orders for a full break, it's split into three parts.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/32183db7-d3b9c871-900f0cec-deb17328) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/32183db7-d3b9c871-900f0cec-deb17328) ⋅ [View on map](https://yandex.com/courier/mvrp-map#32183db7-d3b9c871-900f0cec-deb17328)

**Example 2** 

The total break duration `rest_duration_s` is two hours (`rest_duration_s` = 7200). It's split into two parts (`max_split_parts` = 2). At the same time:
* `min_split_part_duration_s` = 2400 (40 minutes).
* `min_first_split_part_duration_s` = 4800 (1 hour 20 minutes).
* `min_last_split_part_duration_s` = 2400 (40 minutes).

The first part (1 hour 20 minutes) is split from the total break time. 40 minutes of the initial break remain. The second part (40 minutes) is split from them.

As a result, the sum of the break parts will not exceed its total duration and will amount to two hours (7200 seconds).

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/1aef3a12-45d6d02d-63d9de06-e2f67733) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/1aef3a12-45d6d02d-63d9de06-e2f67733) ⋅ [View on map](https://yandex.com/courier/mvrp-map#1aef3a12-45d6d02d-63d9de06-e2f67733)

**Example 3**

The same as in example 2, but the duration of the second part of the break is increased by 5 minutes (`min_last_split_part_duration_s` = 2700). 

The first part (1 hour and 20 minutes) is split from the total break time. 40 minutes of the initial break remain. The second part must be split from the remaining 40 minutes, but `min_last_split_part_duration_s` = 2700 (45 minutes). The remaining time can't be negative, so the duration of the second part will be increased to 45 minutes to minimally comply with the condition `min_last_split_part_duration_s` = 2700.

As a result, the sum of the duration of the break parts will exceed the initially set duration by 5 minutes, amounting to 2 hours and 5 minutes (7500 seconds).

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/64172db6-471aedde-5fa65091-75c4961d) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/64172db6-471aedde-5fa65091-75c4961d) ⋅ [View on map](https://yandex.com/courier/mvrp-map#64172db6-471aedde-5fa65091-75c4961d)

### Breaks during order handling {#rest-during-service}

#|
||**Parameter** | **Value** | **Example**||
||`can_rest_during_service` | Break parameter. Determines whether this break can overlap with the handling time of the order or the depot. Default value is `true`. | 
```json
"breaks": [
  {
    "can_rest_during_service": true,
    "rest_duration_s": 3000,
    "work_time_range_from_start": "1:30 - 2:00"
  },
  ...
]    
```
||
||`can_have_rest_during_service` | Order or depot parameter. Determines whether this break can overlap with the handling time of this order or depot. Default value is `true`. | 
```json
"locations": [
  {
    "id": 123,
    "can_have_rest_during_service": true,    
    "service_duration_s": 600,  
    ...
  }
]
```
||
|#

By default, breaks can overlap with the handling time of an order or depot. In routes, these breaks are indicated before the order or depot. The start time `arrival_time_s` and end time `departure_time_s` of the break coincide with the `arrival_time_s` and `departure_time_s` of the order or depot. Inside this overall interval, the handling time duration is determined by the parameter `service_duration_s`. In the response for such an order or depot, the field `is_after_service_work_break` = `true` is added to indicate that handling starts after the break. 

If `can_rest_during_service` = `true`, the break can be scheduled as the first location in the shift. For regular breaks that don't overlap with the handling time, this is impossible.

To prevent breaks from overlapping with the handling time, set `can_have_rest_during_service` to `false` for the order or depot and `can_rest_during_service` to `false` for the break. 

**Example 1**

A 60-minute break should be scheduled 3 hours after the start of the route. There are 8 orders in the route and the parameter `can_have_rest_during_service` = `true`. The break overlaps with the handling time for the fourth order, for which the courier arrives 2 hours and 29 minutes after the start of the route and leaves 4 hours later.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/338580ba-2538cbcf-a46717b9-ee793761) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/338580ba-2538cbcf-a46717b9-ee793761) ⋅ [View on map](https://yandex.com/courier/mvrp-map#338580ba-2538cbcf-a46717b9-ee793761)

**Example 2**

The same as in example 1, but orders have the parameter `can_have_rest_during_service` = `false`. The break is scheduled at the fourth order's location, but after handling the order and too late: 3 hour and 39 minutes after the start of the route.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/c16ccac0-c1557635-97a5939d-74058670) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/c16ccac0-c1557635-97a5939d-74058670) ⋅ [View on map](https://yandex.com/courier/mvrp-map#c16ccac0-c1557635-97a5939d-74058670)

### Break chains {#rest-shedule-rest}

The `rest_schedule` can contain many independent `breaks` break chains. Each chain can contain many breaks with special conditions. The start of a break in every chain depends only on the built route. It doesn't depend on breaks in other chains.

#|
||**Example** | **Explanation** | **Can be set**||
||Chain 1: Rest for 15 minutes after every 3 hours of transit.

Chain 2: Rest for 6 hours 8 hours after the shift started. | Breaks in chain 2 depend only on the shift start. They don't depend on the transit and rest schedule in chain 1. | <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0.00 0.00 16.00 13.00" width="16.00" height="13.00"><path fill="#fece06" d="   M 14.06 0.00   L 16.00 0.00   L 16.00 1.81   L 6.69 13.00   L 4.94 13.00   L 0.00 7.44   L 0.00 5.94   C 2.21 3.92 4.10 7.71 5.56 9.07   Q 5.97 9.45 6.33 9.02   L 14.06 0.00   Z"/></svg> ||
||Chain 1: Rest for 15 minutes after every 3 hours of transit.

Chain 2: Rest for 6 hours after every 8 hours of transit. | The start of the break in chain 2 depends on the transit and rest schedule in chain 1. | <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0.00 0.00 16.00 16.00" width="16.00" height="16.00"><path fill="#ababab" d="   M 0.00 0.00   L 2.81 0.00   L 7.71 4.94   Q 8.15 5.39 8.56 4.90   Q 10.95 2.03 14.06 0.00   L 16.00 0.00   L 16.00 2.56   L 11.03 7.70   Q 10.64 8.12 11.04 8.52   L 16.00 13.56   L 16.00 16.00   L 13.44 16.00   L 8.46 11.21   Q 8.00 10.76 7.52 11.20   L 2.44 16.00   L 0.00 16.00   L 0.00 13.94   L 4.95 8.44   Q 5.33 8.02 4.94 7.62   L 0.00 2.44   L 0.00 0.00   Z"/></svg> ||
|#

The order of chains doesn't matter, but you must specify breaks in one chain sequentially.

If the route is completed before the stop (for example, the route is completed in 3 hours, and the stop is scheduled after 4 hours), all the unmade stops are reset.

**Example**

The route is built with 30-minute rest breaks after 4 hours of work. 10 hours after the start of the route, a sleep break is planned. As a result, a sleep break is scheduled 1 hours after a rest break.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/5afcea90-db330372-64c4ac1c-2b031237) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/5afcea90-db330372-64c4ac1c-2b031237) ⋅ [View on map](https://yandex.com/courier/mvrp-map#5afcea90-db330372-64c4ac1c-2b031237)


### Penalties {#penalty}

In some cases, RouteQ can plan routes that violate the rest window. To apply penalties for such violations, use the fields `penalty.late` and `penalty.early`. If the penalty is higher than the savings resulting from the window violation, the route is planned without violations.

#|
||**Parameter** | **Value** | **Example**||
||`penalty.early.fixed` | Penalty for an early break start. | `"penalty": {"early": {"fixed": 1000}}`

Sets a penalty of 1000 for an early break.||
||`penalty.early.minute` | Penalty for every minute of an early break. | `"penalty": {"early": {"minute": 17}}`

Sets a penalty of 17 for every minute of an early break.||
||`penalty.late.fixed` | Penalty for a late break. | `"penalty": {"late": {"fixed": 1000}}`

Sets a penalty of 1000 for a late break.||
||`penalty.late.minute` | Penalty for every minute of a late break. | `"penalty": {"late": {"minute": 17}}`

Sets a penalty of 17 for every minute of a late break.||
|#


### Repeat conditions {#repeatable}

#|
||**Parameter** | **Value** | **Example**||
||`repeatable` | The parameter specifies that the break should be repeated. The quantity and order of repeated breaks within a shift can vary. First, the algorithm allocates all the breaks from the schedule. After that, it repeats them in the same order in which they were planned. | `"repeatable": true`

The break will be repeated before the shift end.||
|#

**Example 1**

The courier delivers orders to a neighboring city and periodic breaks. Breaks are set every 2 hours of the route (`hard_time_range`) using the repeat condition `repeatable`. As a result, the algorithm scheduled four breaks:

- Three breaks lasting 20 minutes every two hours of the route.

- One-hour lunch break.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/d33d8bf9-806b799b-2f75fb75-7cbc9fcb) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/d33d8bf9-806b799b-2f75fb75-7cbc9fcb) ⋅ [View on map](https://yandex.com/courier/mvrp-map#d33d8bf9-806b799b-2f75fb75-7cbc9fcb)

**Example 2**

Same as in example 1, but the route extends over several days, with sleep breaks scheduled every 12 hours:

- The repeat condition `repeatable` is used.

- The minimum and maximum route duration before rest `hard_time_range` = 12:00-12:15.


[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/a84d668e-94b38b-848441ad-82793150) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/a84d668e-94b38b-848441ad-82793150) ⋅ [View on map](https://yandex.com/courier/mvrp-map#a84d668e-94b38b-848441ad-82793150)

**Example 3**

A courier delivers orders containing chemicals, so they need to take a 30-minute break every two hours.

As a result, three breaks are scheduled:

- Two breaks lasting 30 minutes every two hours of the route set with the `repeatable` condition (`hard_time_range`).

- One-hour lunch break.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/54f4b6e5-2d9e918f-4bfc7131-85fd8efa) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/54f4b6e5-2d9e918f-4bfc7131-85fd8efa) ⋅ [View on map](https://yandex.com/courier/mvrp-map#54f4b6e5-2d9e918f-4bfc7131-85fd8efa)

{% cut "Support discontinued" %}

**Combining breaks conditions** {#merge-rests}

#|
||**Parameter** | **Value** | **Example**||
||`before_first_location` | The possibility of combining a break with other breaks before the first order. The break can only be combined with the breaks whose types are specified in `merge_with_types`. | `"before_first_location": true`

The break will be combined with the last break before the first location where the break type is specified in `merge_with_types`. If there is no such break, this break will be made right before the first location. All such breaks must be in a separate chain.||
||`after_last_location` | The possibility of combining a break with other breaks after the last order. The break can only be combined with the breaks whose types are specified in `merge_with_types`. | `"after_last_location": true`

The break will be combined with the first break after the last location where the break type is specified in `merge_with_types`. If there is no such break, this break will be made right after the last location. All such breaks must be in a separate chain.||
||`type` | Break type. | `"type": "Lunch"`

A lunch break.||
||`merge_with_types` | The parameter sets which break types can be combined with the specified break. You can only use it in combination with `after_last_location` or `before_first_location`. | `"merge_with_types": ["Lunch", "Sleep"]`

You can combine this break with a lunch or a sleep break.||
|#

**Break planning conditions** {#route-duration-s}

You can specify additional parameters: make a break mandatory or set the minimum working time for the break start.

#|
||**Parameter** | **Value** | **Example**||
||`necessary_route_duration_s` | The time from the start of the route after which a break must be made. Set in seconds. | `"necessary_route_duration_s": 14400`

Be sure to start the break after 4 hours (14,400 seconds) have passed from the route start.||
||`route_duration_s` | The parameter sets the minimum working time at which a break should be scheduled. If the total working time is less, a break isn't scheduled. Set in seconds. | `"route_duration_s": 14400`

Start the break only if the route lasts at least 4 hours (14,400 seconds).||
|#

**Break start conditions** {#time-range}

The conditions set in the old format are incompatible with the new conditions. For example, you can't simultaneously specify the values of the `work_time_range_till_rest` and `soft_time_range` fields.

#|
||**Parameter** | **Value** | **Example**||
||`work_time_range_from_start` | Working hours from the start of the route. Includes travel time, waiting time, and handling time for orders and depots. The break can't be repeated.

The presence and duration of other breaks are not taken into account. | `work_time_range_from_start` = `01:00:00-03:00:00`

Start the break no earlier than in 1 hour and no later than 3 hours after the start of the route.||
||`work_time_range_till_rest` | Working hours from the last break (or from the start of the route if it's the first break). Includes travel time, waiting time, and handling time for orders and depots. | `work_time_range_till_rest` = `02:00:00-04:00:00`

Start the break no earlier than 2 hours and no later than 4 hours after the shift start (including arrival at the depot, handling time, periods of travel and waiting).||
||`travel_time_range` | Travel time and waiting time from the start of the route. Handling time is not taken into account. | `travel_time_range` = `01:00:00-03:00:00`

Start the break no earlier than 1 hour and no later than 3 hours after the start of the route, taking into account periods and travel and waiting and without taking into account handling time at order locations and at the depots.||
||`continuous_travel_time_range` | Travel time and waiting time from the completion of the previous order. Handling time is not taken into account. | `continuous_travel_time_range` = `02:00:00-03:00:00`

Start the break no earlier than in 2 hours and not later than after 3 hours of continuous travel.||
||`driving_time_range` | Travel time from the start of the route. Waiting time and handling time are not taken into account. | `driving_time_range` = `01:00:00-03:00:00`

Start the break no earlier than 1 hour and no later than 3 hours from the start of the continuous travel.||
||`exact_time_range` | Break start time. The break can't be repeated.

The work start time, the presence and duration of other breaks don't matter.

The break won't start if the route ends before the break start time. | `exact_time_range` = `17:00:00-20:00:00`

Start a break from 17:00 to 20:00.||
|#

**Example 1**

We built a route with a lunch break after 4–5 hours of work in this example. As a result, the algorithm schedules a lunch stop for a courier.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/37e692b5-bdae564d-a7024f21-f2820a8a) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/37e692b5-bdae564d-a7024f21-f2820a8a) ⋅ [View on map](https://yandex.com/courier/mvrp-map#37e692b5-bdae564d-a7024f21-f2820a8a)

**Example 2**

In this example, a route is built between Moscow and St. Petersburg with the first break after 4-4.5 hours, and then with breaks every 2 hours. The algorithm scheduled two breaks.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/84ab39d3-82ab8d68-9a76327-c072149c) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/84ab39d3-82ab8d68-9a76327-c072149c) ⋅ [View on map](https://yandex.com/courier/mvrp-map#84ab39d3-82ab8d68-9a76327-c072149c)

**Example 3**

For two couriers a break is set with the `work_time_range_from_start` condition in 3–4 hours after the start of work, but only if the total duration `route_duration_s` is at least 6 hours. The first courier finishes work in 5 hours, so they work without rest. The second courier works for more than 6 hours, so they get one break.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/47b2d78-5ce05fb2-4d9690d2-d27ceb32) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/47b2d78-5ce05fb2-4d9690d2-d27ceb32) ⋅ [View on map](https://yandex.com/courier/mvrp-map#47b2d78-5ce05fb2-4d9690d2-d27ceb32)

**Example 4**

10-minute breaks are set for every 55–60 minutes of continuous traveling `continuous_travel_time_range`. As a result, a break is scheduled only between points where the travel time is more than 55 minutes.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/6706abe0-8ad97e80-3f94a862-1e3159e1) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/6706abe0-8ad97e80-3f94a862-1e3159e1) ⋅ [View on map](https://yandex.com/courier/mvrp-map#6706abe0-8ad97e80-3f94a862-1e3159e1)

**Example 5**

For couriers, two breaks with the break start condition `work_time_range_till_rest` are scheduled for 2–3 hours after the last break or start of work if this is the first break.

- The first break is 20 minutes.

- The second break is 30 minutes.

The first courier finishes work earlier and gets only the first break. The second courier works longer and gets both breaks.

[API request (JSON)](https://courier.yandex.ru/vrs/api/v1/log/request/ddb6e624-f787348c-dd3493bb-c1cae747) ⋅ [API response](https://courier.yandex.ru/vrs/api/v1/result/ddb6e624-f787348c-dd3493bb-c1cae747) ⋅ [View on map](https://yandex.com/courier/mvrp-map#ddb6e624-f787348c-dd3493bb-c1cae747)

{% endcut %}

{% include [warehouse-feedback](_includes/feedback-81845556eeea.md) %}
