Skip to main content

Overview

Multi-vehicle route optimization (VRP) powered by VROOM: you send JSON describing vehicles and tasks, you get back the optimal assignment and visit order. Distances come from the real OSRM road network — not straight lines.
Try it first? Switch the Live Demo to the Fleet Optimization tab: two vehicles, six tasks, one API call to assign and sequence everything.
Conventions. Coordinates are [lng, lat]. All timings are in seconds, all distances in meters. A time_window is a [start, end] pair with both ends inclusive. A “task” is either a job, a pickup or a delivery.

Endpoint

Quickstart

Input structure

The request body is a JSON object. Only vehicles is required.
request-body.json
A problem with shipments only (no jobs) is valid.

Vehicles

Vehicle fields

Vehicle costs

A non-default per_hour defines travel costs from travel times, so combining it with a custom costs matrix for the same vehicle is inconsistent and returns an error.

Breaks

Start and end

  • start and end are both optional, as long as at least one of them is present.
  • If end is omitted, the route stops at the last visited task, chosen by the optimization process.
  • If start is omitted, the route starts at the first visited task, chosen by the optimization process.
  • Same coordinates for start and end = round trip.

Jobs

An error is returned if two jobs share the same id.

Shipments

A shipment is a pickup and a delivery performed by the same vehicle, pickup first.

Shipment fields

Shipment steps

Same fields as a job, minus the shared keys above:
shipment-example.json

Custom matrices

Provide your own travel-time, distance or cost matrices per profile. Providing durations for all used profiles skips the OSRM table calls entirely:
matrices.json
  • With custom matrices, location_index (tasks) and start_index / end_index (vehicles) become mandatory. location, start and end become optional but are echoed in the response when provided.
  • durations are used for all checks against timing constraints; distances require durations; costs are used in all route cost evaluations.
  • With durations but no distances, distances are fetched from the routing engine when needed (options.g or a non-zero per_km cost).

Getting route geometry back

Set "options": { "g": true } — a top-level field, next to vehicles and jobs:
request-body.json
Every route in the response then carries a polyline and distance:
response-example.json
options.g is the JSON equivalent of upstream VROOM’s -g CLI flag.

Response

The response is a JSON object with code, optionally error, and — on success — summary, routes and unassigned.

Status codes

The error field is present if and only if code is different from 0. See Errors for details.

Summary

Routes

Steps

Each step is one element of the visit order: start → job/pickup/delivery/break → end.

Unassigned

Violations

A violation object has a cause and, for lead_time/delay, a duration in seconds.
In regular solving — the only mode the hosted API exposes — violations arrays are always empty. Upstream VROOM reports violations when choosing ETAs for custom routes (plan mode, -c).

Time Windows

How time windows interact with timing fields A task’s time_windows constrain when its service starts; early arrivals wait. Two ways to express them:
  • Relative: [0, 14400] = within 4 hours of the planning horizon start
  • Absolute: real UNIX timestamps — then arrival values in the output are timestamps too

Semantics notes

With custom matrices, location_index is mandatory and location is optional (but echoed in the response when provided). Without custom matrices, a table call goes to OSRM: location is mandatory and location_index is irrelevant.
Amounts are multidimensional — vehicles carry capacity, jobs delivery/pickup, shipments amount. A vehicle may serve a set of tasks only if the resulting load at each route step stays below capacity for each metric. All job deliveries are assumed loaded at vehicle start; all job pickups are assumed brought back at vehicle end. When using multiple components, put the most limiting metric first.
A task is eligible for a vehicle if and only if the task’s skills set is included in the vehicle’s skills. A task without skills can be served by any vehicle; a vehicle without skills can only serve tasks without skills. Omitting skills defaults to an empty array.
priority is an integer in [0, 100] (default 0). Useful when not all tasks can be performed: higher-priority tasks are included in the solution over lower-priority ones.
Setup models the time it takes to get started at a location, and is not re-applied for consecutive tasks at the same place: the total action time is setup + service on arriving at a new location, but only service for another task at the previous vehicle location.
For a vehicle with type t, the actual service time for a task is service_per_type[t] if provided, otherwise the task’s service. The same applies to setup_per_type and setup.
Providing steps for a vehicle in solving mode forces the search to start from your route as a single search path, instead of several concurrent searches. Only steps with type job, pickup or delivery are used; service_* keys are ignored; an error is returned if the provided route violates any constraint. Plan-mode ETA selection (-c in upstream VROOM) is not exposed by the hosted API.

Size limits

“Tasks” counts jobs plus shipment steps.

JustRouting extensions and compatibility

  • profile is restricted to car and motorcycle — upstream profiles like bike are not available.
  • options is the JSON equivalent of VROOM’s CLI flags; only g (route geometry) is currently supported.
  • Deprecated upstream keys are not supported: job.amount (use delivery/pickup), the top-level matrix (use matrices), step.job (use step.id), summary.amount (use summary.delivery/summary.pickup).
  • The OpenAPI → optimize pages hold the complete, machine-readable schema.
  • Distance Matrix — compute matrices for your own solvers
  • Errors — error codes and formats
  • VROOM API docs — the upstream full input/output schema (our hosted version is compatible)