Back to the blog ·

Adding time windows and capacities to a delivery route API

How to send vehicle capacity, multi-dimensional loads, shifts and delivery time windows to the optimize endpoint, and how to read the unassigned list when a stop cannot be served.

A route that ignores capacity and time is not a delivery plan. It is a list of stops in a short order. Two constraints change the answer more than anything else: how much a vehicle can carry, and when each customer can receive a delivery. This post shows how both are expressed in the Argamin optimize request, what the response says when a constraint cannot be met, and the mistakes that most often cause an empty or strange result.

All examples use POST /optimize. The request format is the same for one vehicle or many.

Capacity is a list, not a number

A vehicle’s capacity is an array. Each position is one dimension of load, for example parcels in position 0 and kilograms in position 1. The same is true for loads on stops: delivery (goods to drop off), pickup (goods to collect) and amount on shipments.

The rules are simple:

  • Every vehicle’s capacity has the same length.
  • Every delivery and pickup array has the same length as those capacities.
  • Each value is a non-negative whole number.

Use one dimension when you only count parcels. Use two when weight matters as well, and make sure the number of parcels and the weight are in the same units across the whole request.

{
"vehicles": [
{ "id": "van-1", "start": { "lat": 51.5072, "lng": -0.1276 }, "capacity": [40, 300] },
{ "id": "van-2", "start": { "lat": 51.5072, "lng": -0.1276 }, "capacity": [20, 120] }
],
"jobs": [
{ "id": "order-1001", "location": { "lat": 51.5155, "lng": -0.0922 }, "delivery": [12, 45] },
{ "id": "order-1002", "location": { "lat": 51.4613, "lng": -0.1156 }, "delivery": [3, 80] }
]
}

Capacity is checked along the route, not only at the depot. A vehicle that picks up at an early stop can run out of room later, and the optimizer accounts for that.

Time windows: the vehicle shift and the stop window

Time is expressed in two places.

  • The vehicle shift. time_window on a vehicle is the period the vehicle may work, for example 08:00 to 17:00.
  • The stop window. time_windows on a job is a list of periods when the stop may be served. A stop can have several windows, for example “morning or evening”.

Times are ISO 8601 with an offset. The Z suffix means UTC. Durations are in seconds, so a 15-minute service is 900.

{
"vehicles": [
{
"id": "van-2",
"start": { "lat": 51.5072, "lng": -0.1276 },
"capacity": [20],
"time_window": { "start": "2026-11-27T08:00:00Z", "end": "2026-11-27T17:00:00Z" }
}
],
"jobs": [
{
"id": "order-1002",
"location": { "lat": 51.4613, "lng": -0.1156 },
"service": 300,
"delivery": [1],
"time_windows": [{ "start": "2026-11-27T09:00:00Z", "end": "2026-11-27T11:00:00Z" }]
}
]
}

A vehicle arriving early waits, and the wait is counted in waiting_time. A vehicle that cannot reach a window in time does not serve that stop. Look for the reason in the response rather than assuming the optimizer ignored the window.

Read the response

The response gives each stop a place in a route, or a reason it was left out. The example below is abbreviated from a two-van request with a capacity problem. The numbers are illustrative, not a benchmark.

{
"summary": { "routes": 2, "unassigned": 1, "duration": 5120, "distance": 41230, "service": 1260, "waiting_time": 1180, "cost": 5120 },
"routes": [
{
"vehicle_id": "van-2",
"duration": 2910,
"distance": 23390,
"service": 780,
"waiting_time": 1180,
"steps": [
{ "type": "start", "location": { "lat": 51.5072, "lng": -0.1276 }, "arrival": "2026-11-27T08:00:00Z", "arrival_offset": 0, "load": [2] },
{ "type": "job", "id": "order-1002", "arrival": "2026-11-27T09:00:00Z", "arrival_offset": 3600, "waiting_time": 1180, "service": 300, "load": [1] }
]
}
],
"unassigned": [
{ "id": "order-1005", "type": "job", "reason": "CAPACITY" }
],
"request_id": "req_2b9d6f1e0c8a4e7f9a3b5c7d1e2f4a6b"
}

Three fields do most of the work:

  • summary.unassigned is the count you alert on. Anything above zero needs a decision.
  • unassigned[].reason is one of TIME_WINDOW, CAPACITY, SKILL, UNREACHABLE or OTHER. Each reason has a different fix: a wider window, a bigger vehicle or a second van, a skill added to a vehicle, or a location that needs correcting.
  • steps[].load shows the load after each step, so you can draw the truck fill and see where the limit bites.

Common mistakes

Mismatched array lengths. A capacity with two positions and a delivery with one position is a malformed request. Keep the lengths equal. A client error is never billed.

A window outside the shift. A stop window that falls outside the vehicle’s shift usually ends up in unassigned with reason TIME_WINDOW. Check that the dates are the same day as the shift.

Time without an offset. 2026-11-27T09:00:00 without Z or an offset is ambiguous. Always send an explicit offset.

Treating an empty unassigned as a guarantee. It means the optimizer placed every stop within the limits you sent. It does not check that your data is correct. Keep the coordinates and the windows in your own system up to date.

Limits to plan for

Synchronous POST /optimize accepts up to 200 stops and 20 vehicles. Accounts without a card have a lower limit of 50 stops and 5 vehicles. Asynchronous jobs at POST /optimize/jobs accept up to 1,000 stops and 100 vehicles, return 202 straight away, and can notify you by webhook. Use a job when the problem is larger than the sync limit, or when you do not want the HTTP connection to wait for the solver.

Coordinates must be inside a covered region. A point outside one returns OUT_OF_COVERAGE, and that call is not billed.

Once capacities and windows are right, the next question is which call shape matches the problem. See VRP vs TSP, and for cost, the pricing explainer.

Compare the cost on the pricing page, or join the waitlist.