# Plan data model

Understand the proposed direct-plan payload.

> **Proposed public API.** The direct submission contract is a design proposal. Its examples are illustrative.

## Vehicles

| Field | Type | Description |
| --- | --- | --- |
| id | string | Unique vehicle identifier within the plan |
| startLocation | object | Starting coordinates |
| endLocation | object | Finishing coordinates; may differ from start |
| capacity | integer array | Maximum load in each dimension, in the same order as each job’s load |
| breaks | array of objects | Optional break rules for this vehicle. Omit or send an empty array for no rules. |
| timeWindow | object | Vehicle availability interval |

Different vehicles may have different depots. The proposed minimal contract requires both start and end coordinates; open-route support must be verified separately.

## Jobs

For a single service visit, put the location and service duration directly on the job.

| Field | Type | Description |
| --- | --- | --- |
| id | string | Unique job identifier within the plan |
| location | object | Visit coordinates |
| serviceDuration | number | Time spent servicing this job, in minutes. For example, 5 means five minutes. |
| load | integer array | Amount consumed in each capacity dimension |
| timeWindow | object | Optional window for starting service. Both endpoints are inclusive. |

## Shipment jobs

Represent a shipment as one entry in `jobs` with an `id`, a shared `load`, and two stops. Omit the job-level `location` field. The vehicle collects the load at `pickup.location` and drops it off at `delivery.location`.

| Field | Type | Description |
| --- | --- | --- |
| `pickup.location` | object | Coordinates where the vehicle collects the shipment, using `latitude` and `longitude` |
| `pickup.serviceDuration` | number | Minutes spent at the pickup stop |
| `delivery.location` | object | Coordinates where the vehicle delivers the shipment, using `latitude` and `longitude` |
| `delivery.serviceDuration` | number | Minutes spent at the delivery stop |

See the [pickup and delivery example](/create/#pickup-and-delivery-example) for a shipment with a 5-minute pickup and a 10-minute delivery.

## Load dimensions

Choose a unit for each array position and keep the order and length consistent across vehicles and jobs. Use nonnegative whole numbers. In the example, `[4, 800]` means room for four pallets and 800 kg. A job with `load: [1, 250]` uses one pallet space and 250 kg. A load of `[1, 900]` exceeds this van’s weight limit even with pallet spaces available. Use a one-element array for a single dimension, and use zero for an unused dimension.

In the implemented routing problem the fields are `vehicles[].capacity` and `jobs[].demand`, both integer arrays. The current Dispatcher plan-file import accepts scalar crew `capacity` and job `load` and converts each to one routing dimension.

## Vehicle breaks

In the proposed format, put each rule in `vehicles[].breaks`. A windowed break has a positive integer `durationMinutes` and a `timeWindow` with the earliest and latest permitted **start** timestamps. For the example van, a 30-minute break starting at 12:00 UTC finishes at 12:30 UTC.

The implemented routing format uses `duration` in seconds and `time_window` for the start window. It also supports a work-time trigger (`trigger_after`, in seconds), optionally combined with the window. The [implemented import example](/plan-submission.md) shows the crew-file format.

## Coordinates

| Field | Type | Description |
| --- | --- | --- |
| latitude | number | Decimal degrees, −90 to 90 |
| longitude | number | Decimal degrees, −180 to 180 |

Use named coordinate properties to avoid ordering ambiguity. The coordinate system is proposed as WGS 84.

## Time windows

Use UTC timestamps ending in an uppercase `Z` for all vehicle, job and break windows. The `Z` means UTC. Convert local times to UTC before submitting the plan. For example, send 09:00 in Stockholm on December 1, 2026 as `2026-12-01T08:00:00Z`. Response timestamps such as `createdAt` and `expiresAt` use the same format.

Each window’s `start` must be at or before its `end`. For a job, service may start at any time from `start` through `end`, inclusive. Service may finish after `end`. For example, a 10-minute visit with a window ending at 15:00 UTC may start at 15:00 UTC and finish at 15:10 UTC.

If the stop must finish within the window, subtract `serviceDuration` (in minutes) from the required finish time and use the result as `timeWindow.end`. For a 10-minute stop that must finish by 15:00 UTC, set `timeWindow.end` to `2026-12-01T14:50:00Z` for a December 1, 2026 visit.

## Example

```json
{
  "name": "Stockholm service visits",
  "expiryHours": 24,
  "vehicles": [
    {
      "id": "van-1",
      "startLocation": {
        "latitude": 59.3326,
        "longitude": 18.0649
      },
      "endLocation": {
        "latitude": 59.347,
        "longitude": 18.038
      },
      "capacity": [4, 800],
      "breaks": [
        {
          "durationMinutes": 30,
          "timeWindow": {
            "start": "2026-12-01T11:00:00Z",
            "end": "2026-12-01T12:00:00Z"
          }
        }
      ],
      "timeWindow": {
        "start": "2026-12-01T07:00:00Z",
        "end": "2026-12-01T16:00:00Z"
      }
    }
  ],
  "jobs": [
    {
      "id": "job-1",
      "location": {
        "latitude": 59.34,
        "longitude": 18.05
      },
      "serviceDuration": 5,
      "load": [1, 250],
      "timeWindow": {
        "start": "2026-12-01T08:00:00Z",
        "end": "2026-12-01T15:00:00Z"
      }
    },
    {
      "id": "job-2",
      "location": {
        "latitude": 59.345,
        "longitude": 18.045
      },
      "serviceDuration": 10,
      "load": [2, 300]
    }
  ]
}
```
