> ## Documentation Index
> Fetch the complete documentation index at: https://developers.kardinal.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Heavy long distance

> Heavy long-distance example: reserved warehouse slots, load-aware CO2 accounting, self-closing consolidation loops, and a real overnight rest between loading and delivery.

A heavy long-distance operation runs multi-day corridors between distribution points, mixing scheduled warehouse pickups, loop tours that consolidate full loads without a fixed endpoint, and a real overnight rest built into the schedule rather than assumed. Fuel and CO2 costs scale with the actual load carried, not just the kilometres driven.

## What makes this vertical distinctive

* **Reserved warehouse slots** — an early pickup window at the warehouse is reserved for one specific vehicle, on top of the standard hours everyone else sees.
* **Load-aware CO2 accounting** — CO2 is calculated from the load actually carried per leg, not from distance alone.
* **Consolidation loops** — a truck with no fixed home base opens and closes its tour on whichever point it visits first, minimizing empty running.
* **A real overnight rest** — a two-day route plans an explicit rest period, not just a working window that happens to span two days.

## Combined example

```json theme={null}
{
  "tz": "Europe/Paris",
  "resources": [
    {
      "id": "truck-1",
      "vehicleProfile": { "type": "truck", "grossWeight": 40000 },
      "workingTimeWindow": { "begin": "2026-08-03 06:00", "end": "2026-08-04 20:00" },
      "capacities": { "weight": 24000 },
      "maxWorkingDuration": "PT37H",
      "breaks": [
        { "type": "workingDurationSlidingBreak", "minBreakDuration": "PT11H", "maxInterBreakDuration": "PT12H" },
        { "type": "timeWindowBreak", "duration": "PT11H", "timeWindow": { "begin": "2026-08-03 19:00", "end": "2026-08-04 07:00" } }
      ],
      "CO2EmissionCalculation": {
        "km": { "costCoeff": 0.82 },
        "costPerCapacityPerTravelledKm": { "weight": { "costCoeff": 1.45e-05 } }
      }
    },
    {
      "id": "tractor-reserved-1",
      "vehicleProfile": { "type": "truck" },
      "tags": ["dock-slot:reserved-a"]
    },
    {
      "id": "truck-loops-1",
      "vehicleProfile": { "type": "truck" },
      "arrival": "atFirstPosition",
      "capacities": { "weight": 24000 }
    }
  ],
  "orders": [
    {
      "id": "order-warehouse-dock",
      "stops": [
        {
          "type": "single",
          "id": "stop-warehouse-dock",
          "position": { "lon": 2.55, "lat": 48.635 },
          "kind": "pickup",
          "operationDuration": "PT30M",
          "authorizedTimeWindows": [
            { "begin": "2026-08-03 06:00", "end": "2026-08-03 07:00", "resourceTags": ["dock-slot:reserved-a"] }
          ]
        }
      ]
    },
    {
      "id": "order-loop-0",
      "stops": [
        { "type": "single", "id": "stop-pickup-0", "position": { "lon": 2.595, "lat": 48.63 }, "kind": "pickup", "operationDuration": "PT30M", "capacities": { "weight": 8000 } },
        { "type": "single", "id": "stop-delivery-0", "position": { "lon": 2.568, "lat": 48.606 }, "kind": "delivery", "operationDuration": "PT30M", "capacities": { "weight": 8000 } }
      ],
      "successiveStops": true
    },
    {
      "id": "order-day2-delivery",
      "stops": [
        {
          "type": "single",
          "id": "stop-day2-load",
          "position": { "lon": 2.58, "lat": 48.62 },
          "kind": "pickup",
          "operationDuration": "PT45M",
          "capacities": { "weight": 10000 },
          "authorizedTimeWindows": [{ "begin": "2026-08-03 16:00", "end": "2026-08-03 18:00" }]
        },
        {
          "type": "single",
          "id": "stop-day2-delivery",
          "position": { "lon": 2.605, "lat": 48.615 },
          "kind": "delivery",
          "operationDuration": "PT25M",
          "capacities": { "weight": 10000 },
          "authorizedTimeWindows": [{ "begin": "2026-08-04 08:00", "end": "2026-08-04 18:00" }]
        }
      ]
    }
  ]
}
```

### Reserved warehouse slots

`order-warehouse-dock`'s window carries `resourceTags: ["dock-slot:reserved-a"]` — only `tractor-reserved-1`, which holds that tag, can be assigned this early slot; every other resource is restricted to whatever untagged window exists elsewhere on the same stop. See [Restricting a window to specific resources](/guides/advanced-constraints#restricting-a-window-to-specific-resources) — the exact worked example this follows.

### Emissions scaled to load carried

`truck-1.CO2EmissionCalculation` mirrors the `Cost` object's shape: a flat `km` rate plus `costPerCapacityPerTravelledKm`, which multiplies the `weight` actually carried on each leg by the distance travelled. A fully loaded leg reports more CO2 than an empty return leg over the same kilometres, instead of both being priced identically by distance alone.

### Consolidation loops

`truck-loops-1` has no `departure` and sets `arrival: "atFirstPosition"` — its tour closes on whichever stop the engine assigns first, rather than a fixed depot. Paired with `order-loop-0`'s pickup-then-delivery stops (`successiveStops: true`, matching `weight` capacities), this lets the engine build a self-contained loop sized to whatever load it consolidates. See [Depot vs. position](/reference/data-model#depot-vs-position) for how `"atFirstPosition"` fits alongside a normal fixed `departure`/`arrival`.

### A real overnight rest

In the full payload, only `truck-1` works two days. The four other trucks work day 1 only. Without that limit, a truck with no rest to take would pick up the day-2 order and wait at the client all night.

`order-day2-delivery` has two stops. The goods are loaded on day 1, between 16:00 and 18:00, and delivered on day 2. So the truck that carries them keeps the goods overnight.

The sliding break and the night `timeWindowBreak` reserve the rest. It falls right after the last stop `truck-1` serves on day 1, because, currently, a break is only taken where the vehicle stands. See [Where a break can fall](/guides/advanced-constraints#where-a-break-can-fall).

`maxWorkingDuration` counts breaks and waiting too. That is why `truck-1` has `PT37H`: it covers both working days and the 11-hour rest between them. With a one-day cap such as 13 hours, both stops of `order-day2-delivery` stay unplaced, and the engine returns no error.

In the solution, the break starts as soon as that last stop of day 1 is done. It can last more than 11 hours, because waiting at that place is shown as part of the break. For the general pattern, see [Modeling multi-day sleepovers](/guides/advanced-constraints#modeling-multi-day-sleepovers).

## Full payload

> **Full payload — ready to submit as POST /plans**
>
> The preceding example isolates the four mechanisms this vertical needs; this expands it to the scale of a real working day — a full fleet schedule (`workingTimeWindow`, `departure`, `arrival`), the complete `objectives` list, and enough orders (including an LTL pickup/dropoff pair unloaded in strict LIFO order) to look like an actual route rather than a minimal illustration. Submit it as-is via [`POST /plans`](/api-reference/plan/create-a-plan) — the service assigns the plan's `id`, so don't include one of your own. Its datetimes are local times, read in the plan's `tz` (`Europe/Paris`); see [Dates and time zones](/reference/data-model#dates-and-time-zones).
>
> ```json theme={null}
> {
>   "tz": "Europe/Paris",
>   "resources": [
>     {
>       "id": "truck-1",
>       "vehicleProfile": { "type": "truck", "grossWeight": 40000, "avoidTunnel": true, "tunnelCategory": "D", "shippedHazardousGoods": ["flammable", "corrosive"] },
>       "workingTimeWindow": { "begin": "2026-08-03 06:00", "end": "2026-08-04 20:00" },
>       "departure": { "lon": 2.58, "lat": 48.62 },
>       "arrival": { "lon": 2.58, "lat": 48.62 },
>       "capacities": { "weight": 24000 },
>       "breaks": [
>         { "type": "workingDurationSlidingBreak", "minBreakDuration": "PT11H", "maxInterBreakDuration": "PT12H" },
>         { "type": "timeWindowBreak", "duration": "PT11H", "timeWindow": { "begin": "2026-08-03 19:00", "end": "2026-08-04 07:00" } }
>       ],
>       "maxWorkingDuration": "PT37H",
>       "cost": { "workedHours": { "costFloor": 8, "costCoeff": 1, "overcostFloor": 10, "overcostCoeff": 1.25 } },
>       "CO2EmissionCalculation": { "km": { "costCoeff": 0.82 }, "costPerCapacityPerTravelledKm": { "weight": { "costCoeff": 1.45e-05 } } }
>     },
>     {
>       "id": "tractor-preloaded-1",
>       "vehicleProfile": { "type": "truck" },
>       "workingTimeWindow": { "begin": "2026-08-03 05:00", "end": "2026-08-03 20:00" },
>       "departure": { "lon": 2.572, "lat": 48.594 },
>       "arrival": { "lon": 2.58, "lat": 48.62 },
>       "capacities": { "weight": 18000 },
>       "tags": ["trailer"]
>     },
>     {
>       "id": "tractor-reserved-1",
>       "vehicleProfile": { "type": "truck" },
>       "workingTimeWindow": { "begin": "2026-08-03 05:00", "end": "2026-08-03 20:00" },
>       "departure": { "lon": 2.58, "lat": 48.62 },
>       "arrival": { "lon": 2.58, "lat": 48.62 },
>       "tags": ["dock-slot:reserved-a"]
>     },
>     {
>       "id": "truck-loops-1",
>       "vehicleProfile": { "type": "truck" },
>       "workingTimeWindow": { "begin": "2026-08-03 05:00", "end": "2026-08-03 20:00" },
>       "arrival": "atFirstPosition",
>       "capacities": { "weight": 24000 }
>     },
>     {
>       "id": "tanker-1",
>       "vehicleProfile": { "type": "truck" },
>       "workingTimeWindow": { "begin": "2026-08-03 05:00", "end": "2026-08-03 20:00" },
>       "departure": { "lon": 2.58, "lat": 48.62 },
>       "arrival": { "lon": 2.58, "lat": 48.62 },
>       "capacities": { "petrol": 12000, "diesel": 9000, "additive": 1500 }
>     }
>   ],
>   "orders": [
>     {
>       "id": "order-loop-0",
>       "stops": [
>         { "type": "single", "id": "stop-pickup-0", "position": { "lon": 2.595, "lat": 48.63 }, "kind": "pickup", "operationDuration": "PT30M", "capacities": { "weight": 8000 } },
>         { "type": "single", "id": "stop-delivery-0", "position": { "lon": 2.568, "lat": 48.606 }, "kind": "delivery", "operationDuration": "PT30M", "capacities": { "weight": 8000 } }
>       ],
>       "successiveStops": true
>     },
>     {
>       "id": "order-loop-1",
>       "stops": [
>         { "type": "single", "id": "stop-pickup-1", "position": { "lon": 2.56, "lat": 48.628 }, "kind": "pickup", "operationDuration": "PT30M", "capacities": { "weight": 8000 } },
>         { "type": "single", "id": "stop-delivery-1", "position": { "lon": 2.605, "lat": 48.615 }, "kind": "delivery", "operationDuration": "PT30M", "capacities": { "weight": 8000 } }
>       ],
>       "successiveStops": true
>     },
>     {
>       "id": "order-ltl-pickup-1",
>       "stops": [{ "type": "single", "id": "stop-ltl-pickup-1", "position": { "lon": 2.585, "lat": 48.642 }, "kind": "pickup", "operationDuration": "PT20M", "capacities": { "weight": 2000 } }]
>     },
>     {
>       "id": "order-ltl-pickup-2",
>       "stops": [{ "type": "single", "id": "stop-ltl-pickup-2", "position": { "lon": 2.572, "lat": 48.594 }, "kind": "pickup", "operationDuration": "PT20M", "capacities": { "weight": 3000 } }]
>     },
>     {
>       "id": "order-ltl-dropoff-1",
>       "stops": [{ "type": "single", "id": "stop-ltl-dropoff-1", "position": { "lon": 2.595, "lat": 48.63 }, "kind": "delivery", "operationDuration": "PT20M", "capacities": { "weight": 2000 } }]
>     },
>     {
>       "id": "order-ltl-dropoff-2",
>       "stops": [{ "type": "single", "id": "stop-ltl-dropoff-2", "position": { "lon": 2.56, "lat": 48.628 }, "kind": "delivery", "operationDuration": "PT20M", "capacities": { "weight": 3000 } }]
>     },
>     {
>       "id": "order-day1-delivery",
>       "stops": [
>         { "type": "single", "id": "stop-day1-delivery", "position": { "lon": 2.59, "lat": 48.602 }, "kind": "delivery", "operationDuration": "PT25M", "authorizedTimeWindows": [{ "begin": "2026-08-03 08:00", "end": "2026-08-03 18:00" }] }
>       ]
>     },
>     {
>       "id": "order-day2-delivery",
>       "stops": [
>         { "type": "single", "id": "stop-day2-load", "position": { "lon": 2.58, "lat": 48.62 }, "kind": "pickup", "operationDuration": "PT45M", "capacities": { "weight": 10000 }, "authorizedTimeWindows": [{ "begin": "2026-08-03 16:00", "end": "2026-08-03 18:00" }] },
>         {
>           "type": "single",
>           "id": "stop-day2-delivery",
>           "position": { "lon": 2.605, "lat": 48.615 },
>           "kind": "delivery",
>           "operationDuration": "PT25M",
>           "capacities": { "weight": 10000 },
>           "authorizedTimeWindows": [{ "begin": "2026-08-04 08:00", "end": "2026-08-04 18:00" }]
>         }
>       ]
>     },
>     {
>       "id": "order-warehouse-dock",
>       "stops": [
>         {
>           "type": "single",
>           "id": "stop-warehouse-dock",
>           "position": { "lon": 2.55, "lat": 48.635 },
>           "kind": "pickup",
>           "operationDuration": "PT30M",
>           "authorizedTimeWindows": [{ "begin": "2026-08-03 06:00", "end": "2026-08-03 07:00", "resourceTags": ["dock-slot:reserved-a"] }]
>         }
>       ]
>     },
>     {
>       "id": "order-trailer-0",
>       "stops": [
>         { "type": "single", "id": "stop-trailer-load-0", "position": { "lon": 2.572, "lat": 48.594 }, "kind": "pickup", "operationDuration": "PT45M", "capacities": { "weight": 6000 }, "tags": ["trailer:loaded"] },
>         { "type": "single", "id": "stop-trailer-delivery-0", "position": { "lon": 2.595, "lat": 48.63 }, "kind": "delivery", "operationDuration": "PT25M", "capacities": { "weight": 6000 } }
>       ]
>     },
>     {
>       "id": "order-trailer-1",
>       "stops": [
>         { "type": "single", "id": "stop-trailer-load-1", "position": { "lon": 2.572, "lat": 48.594 }, "kind": "pickup", "operationDuration": "PT45M", "capacities": { "weight": 6000 }, "tags": ["trailer:loaded"] },
>         { "type": "single", "id": "stop-trailer-delivery-1", "position": { "lon": 2.56, "lat": 48.628 }, "kind": "delivery", "operationDuration": "PT25M", "capacities": { "weight": 6000 } }
>       ]
>     },
>     {
>       "id": "order-petrol",
>       "stops": [{ "type": "single", "id": "stop-petrol", "position": { "lon": 2.59, "lat": 48.602 }, "kind": "delivery", "operationDuration": "PT20M", "capacities": { "petrol": 4000 } }]
>     },
>     {
>       "id": "order-diesel",
>       "stops": [{ "type": "single", "id": "stop-diesel", "position": { "lon": 2.56, "lat": 48.628 }, "kind": "delivery", "operationDuration": "PT20M", "capacities": { "diesel": 3500 } }]
>     },
>     {
>       "id": "order-additive",
>       "stops": [{ "type": "single", "id": "stop-additive", "position": { "lon": 2.595, "lat": 48.63 }, "kind": "delivery", "operationDuration": "PT15M", "capacities": { "additive": 500 } }]
>     }
>   ],
>   "objectives": ["maximizeMandatoryStops", "minimizeCosts", "minimizeDistance", "minimizeWorkingDuration"],
>   "additionalConstraints": [
>     { "type": "removalStrategy", "removalStrategy": "lifo", "name": "ltl-unload-in-lifo-order" }
>   ],
>   "operationDurationPoliciesByResourceTag": { "trailer": [{ "policy": "withoutFirstOperationDuration", "stopTags": ["trailer:loaded"] }] }
> }
> ```

## See also

* [Modeling advanced constraints](/guides/advanced-constraints#modeling-multi-day-sleepovers) — multi-day `workingTimeWindow` and the sliding break that actually forces rest.
* [Modeling advanced constraints](/guides/advanced-constraints#restricting-a-window-to-specific-resources) — `resourceTags` on a time window.
* [Data model](/reference/data-model#depot-vs-position) — `departure`/`arrival`, including `"atFirstPosition"`.

Ready to model an operation like this one? [Send your first API call](/getting-started/first-api-call) with your own data, or contact [customer.success@kardinal.ai](mailto:customer.success@kardinal.ai) to walk through your specific constraints.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.