Documentation menu
POST/optimise
Also served at /optimize: the same operation and price.
Access and price
| Auth | An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Needs a full key; a browser (maps) key is refused. |
|---|---|
| Price | 10 calls per started block of the engine's matrix-pair limit over the problem's unique locations (10 up to 50 locations). Class: standard, or premium for truck and ADR work. Published as unit_rules.optimise in /pricing.json. |
| Premium | When the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true |
What it does
Route-optimisation endpoint. /optimize is an alias.
An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: 10 calls per started block of the engine's matrix-pair limit over the problem's unique locations (10 up to 50 locations).
Also served at /optimize (the American spelling): the same handler, body, answer and price.
Call it
curl -fsS -X POST "https://api.mapmap.ai/optimise" \
-H "Authorization: Bearer $MAPMAP_KEY" \
-H "Content-Type: application/json" \
-d @request.jsonRequest body
application/json
Optimisation problem: vehicles (id, start/end, capacity, skills, time_window, plus breaks, max_travel_time, max_tasks and a costs model), jobs (id, location, service_s, delivery, pickup, skills, time_windows), optional shipments (pickup+delivery pairs), costing (auto|truck|bicycle|pedestrian|motor_scooter), optional Valhalla-style costing_options and an optional top-level adr vehicle profile (as on /route). Set eu_drivers_hours (true or {driving_before_break_s, break_duration_s}) to auto-generate EC 561/2006 rest breaks for windowed vehicles without explicit breaks (single-shift approximation). An optional emissions object (vehicle_category, fuel, euro_standard, as on /route) reports which of the problem's own locations sit in a UK clean-air zone and what this vehicle pays there; avoid_zones: true additionally keeps the internal travel-time matrix out of those zones. Optional territories ([{id, polygon}], GeoJSON [lon, lat] rings) plus per-vehicle territory_ids confine a vehicle to named rounds: it may serve a task only if the task sits inside at least one of its territories, a vehicle with no territory_ids serves anywhere, and a task inside no territory at all is servable by unrestricted vehicles only. Per-vehicle reloads ({max_trips, reload_time_s, depot}) lets a vehicle return to its depot, reload and go out again; the waste-collection tipping round: the vehicle is split into one virtual vehicle per trip and its time_window (which becomes required) is partitioned into consecutive trip windows separated by reload_time_s, so capacity, max_tasks, max_travel_time and costs apply PER TRIP. Optional relax_if_unassigned ({time_windows_by_s, allow_overtime_s}) re-solves ONCE with those caps applied when the first solve leaves work unassigned, keeps the relaxed plan only if it assigns more, and bills two solves when it runs. /optimize is accepted as an alias. Fair use: at most 200 unique locations per request, and no wider than the routing engine's matrix span (1,500 km on the hosted gateway, 400 km stock on a self-host)
Example: From website/public/docs/optimisation.md:241
{
"adr": {
"dimensions": {
"gross_weight_t": 40,
"height_m": 4,
"length_m": 16.5,
"width_m": 2.55
},
"hazmat": true,
"tunnel_code": "C"
},
"costing": "truck",
"jobs": [
{
"delivery": [
2
],
"id": 10,
"location": {
"lat": 52.4862,
"lon": -1.8904
},
"service_s": 300
},
{
"delivery": [
3
],
"id": 11,
"location": {
"lat": 53.4808,
"lon": -2.2426
},
"service_s": 300
}
],
"vehicles": [
{
"capacity": [
10
],
"end": {
"lat": 51.5074,
"lon": -0.1278
},
"id": 1,
"start": {
"lat": 51.5074,
"lon": -0.1278
},
"time_window": [
28800,
64800
]
}
]
}Responses
summary, unassigned and routes[] with ordered steps[] (durations in seconds, distances in metres, locations echoed as {lat, lon}), plus the matrix profile used and, when any location sits in a UK clean-air zone or avoid_zones was set, a zones block naming those zones and the avoidance applied to the matrix. When territories was given, a territories block reports per-territory job counts (inside, assigned, unassigned), the jobs outside every territory, anything no vehicle was allowed to serve, and the semantics in force. When any vehicle declared reloads, each route carries its trip (1-based) beside the caller's own vehicle id, summary.routes counts TRIPS, and a reloads block reports trips used vs allowed, the depot, the trip windows and the sequencing approximation. When relax_if_unassigned was given, a relaxation block states whether a second solve ran, whether its plan is the one returned, what was widened and what is still unassigned| Field | Type | Required | Description |
|---|---|---|---|
| code | integer | no | 0 when solved. |
| eta_calibration | object | no | The typical-delay calibration applied to the plan's times. |
| profile | string | no | The costing the plan was solved for. |
| relaxation | object | no | Constraints relaxed to find a plan, and whether a second solve ran. |
| reloads | not stated | no | Depot reload stops, when vehicles reload. |
| routes | object[] | no | One route per used vehicle: vehicle, cost, distance,
duration, service, waiting_time and steps (start,
job, pickup, delivery, break, end) with arrival
times and location. |
| solver | string | no | The solver used. Off by default. |
| summary | object | no | Totals: cost, distance (metres), duration, service and
waiting_time (seconds), routes and unassigned counts. |
| territories | not stated | no | Per territory polygon the caller sent: the jobs inside it and the jobs the plan assigned. Present when territories were sent. |
| unassigned | object[] | no | Jobs no vehicle could take. |
| zones | object | no | Clean-air zone charges at the plan's stops (at_locations), with
basis and caveats. |
Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /optimise, one car from Trafalgar Square with two London jobs; lists trimmed to their first items
{
"code": 0,
"eta_calibration": {
"applied": true,
"cells_calibrated": 6,
"cells_not_walked": 0,
"cells_unchanged": 3,
"method": "gb_typical_delay_v1",
"note": "Local roads in Great Britain carry no live traffic data, so the time on them includes the junction and congestion delay a typical car meets at this time of day, from Department for Transport statistics, on top of the routing engine's free-flowing time: the same delay POST /route adds, applied to the path each cell was costed on. It is a typical figure, not live traffic. Motorways, roads covered by National Highways traffic data and roads outside Great Britain keep the engine's own time.",
"period": "all_day",
"sources": [
"Department for Transport, tables CGN0503 and CGN0504: average speed and delay on local 'A' roads in England, urban and rural, by time of day, rolling year to June 2026"
]
},
"profile": "auto",
"routes": [
{
"cost": 1376,
"distance": 7749,
"duration": 1376,
"service": 600,
"steps": [
{
"arrival": 0,
"duration": 0,
"location": {
"lat": 51.508,
"lon": -0.1281
},
"service": 0,
"type": "start",
"waiting_time": 0
},
{
"arrival": 414,
"duration": 414,
"id": 10,
"location": {
"lat": 51.5138,
"lon": -0.0984
},
"service": 300,
"type": "job",
"waiting_time": 0
}
],
"vehicle": 1,
"waiting_time": 0
}
],
"summary": {
"cost": 1376,
"distance": 7749,
"duration": 1376,
"routes": 1,
"service": 600,
"unassigned": 0,
"waiting_time": 0
},
"unassigned": [],
"zones": {
"at_locations": [
{
"assessment": "unknown",
"currency": "GBP",
"daily_charge": null,
"enforcement": "charge",
"id": "gb-london-lez",
"locations_inside": 3,
"name": "London Low Emission Zone",
"operator": "Transport for London",
"source": {
"checked": "2026-09-03",
"licence": "TfL website content; reuse of tfl.gov.uk page content is restricted by TfL's website terms. These figures are transcribed by hand for citation, not extracted as a dataset.",
"publisher": "Transport for London",
"url": "https://tfl.gov.uk/modes/driving/low-emission-zone/make-a-payment"
},
"type": "lez"
},
{
"assessment": "unknown",
"currency": "GBP",
"daily_charge": null,
"enforcement": "charge",
"id": "gb-london-ulez",
"locations_inside": 3,
"name": "London Ultra Low Emission Zone",
"operator": "Transport for London",
"source": {
"checked": "2026-09-03",
"licence": "TfL website content; reuse of tfl.gov.uk page content is restricted by TfL's website terms. These figures are transcribed by hand for citation, not extracted as a dataset.",
"publisher": "Transport for London",
"url": "https://tfl.gov.uk/modes/driving/ultra-low-emission-zone/cars"
},
"type": "ulez"
}
],
"basis": "the optimiser is fed a travel-time matrix, not road geometry, so this block reports the zones this problem's own locations sit in and the avoidance applied to the matrix. It does NOT enumerate the zones the driven roads pass through. Route each vehicle's ordered stops through POST /route with the same `emissions` object for that.",
"caveats": "Zone boundaries are simplified from the published geometry to the tolerance stated on each zone, so a route running within that distance of a boundary may be classified either way. Charges are the published daily amounts as at each zone's `checked` date, quoted per zone per day and never summed into any routing cost; a vehicle crossing the same zone twice in a day pays once, and this estimate does not model residency, disability, historic-vehicle or trade exemptions, discounts, or accounts you may already hold. Verify against the cited source before relying on a figure.",
"note": "charge depends on vehicle emissions, supply `emissions` (vehicle_category, fuel, euro_standard) to resolve"
}
}application/problem+json · Problem
unauthorized); the body carries signup, docs and a one-call hint for a free keyapplication/problem+json · Problem
X-PAYMENT). Not problem+jsonapplication/json · X402PaymentRequired
scope-insufficient), a request from an origin the key does not allow (origin-not-allowed), or an account restriction (forbidden)application/problem+json · Problem
text/plain
max_matrix_distance (1,500 km on the hosted gateway, 400 km stock on a self-host: the internal matrix is chunked to fit the engine's pair ceiling, but its span cannot be chunked around), or a problem too large for the solver's cost arithmetic (optimisation-beyond-solver, not billed)application/problem+json · Problem
rate-limited, with Retry-After), or monthly quota exhausted with no payment path (quota-exceeded)application/problem+json · Problem
application/problem+json · Problem
application/problem+json · Problem
request-timeout)application/problem+json · Problem
Error bodies follow the shared problem model documented on API conventions.
Also under Optimisation and jobs
Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_optimise