Documentation menu
POST/matrix
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 | 1 call per started block of 25 elements (sources × targets), at most 10000 elements per request. Class: standard, or premium for truck and ADR work. Published as unit_rules.matrix in /pricing.json. |
| Premium | When the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true |
What it does
Many-to-many travel times and distances between sources and targets.
An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: 1 call per started block of 25 elements (sources × targets), at most 10000 elements per request.
Call it
curl -fsS -X POST "https://api.mapmap.ai/matrix" \
-H "Authorization: Bearer $MAPMAP_KEY" \
-H "Content-Type: application/json" \
-d '{"costing":"truck","costing_options":{"truck":{"height":4,"weight":40}},"sources":[{"lat":51.5074,"lon":-0.1278}],"targets":[{"lat":52.4862,"lon":-1.8904},{"lat":53.4808,"lon":-2.2426}]}'Request body
application/json
Valhalla matrix request JSON: sources, targets, costing, optional units and costing_options. Scenario analysis: optional exclude_polygons; areas whose intersecting roads are avoided, as a JSON array of rings of [lon, lat] pairs (note the lon-first order), e.g. [[[-0.1,51.5],[-0.11,51.5],[-0.11,51.52]]], and exclude_locations, {lat, lon} objects each mapped to its nearest road(s), which are then excluded, so "close this bridge and recompute the matrix" is one request. Valhalla engine only: a GraphHopper-backed deployment ignores both fields. When the first search leaves cells null, the gateway searches once more with a wider snap (radius 1000 m, minimum_reachability 500) at every source and target that did not set its own, keeping every value the caller did set, and takes the second search's value for the null cells only. The retry is never sent when the request carries exclude_locations or exclude_polygons: a wider snap would route round the exclusion, so those cells stay null. Optional top-level snap_retry: false turns the retry off
Example: From website/public/docs/analysis.md:255
{
"costing": "truck",
"costing_options": {
"truck": {
"height": 4,
"weight": 40
}
},
"sources": [
{
"lat": 51.5074,
"lon": -0.1278
}
],
"targets": [
{
"lat": 52.4862,
"lon": -1.8904
},
{
"lat": 53.4808,
"lon": -2.2426
}
]
}Responses
{durations, distances}: row-major seconds and metres, null when unreachable. Car (auto) durations on local roads in Great Britain include typical junction and congestion delay, as on POST /route; then an eta_calibration block names the method, the period, the cell counts and the engine's own engine_durations. When the widened-snap retry filled any cell, a snap_retry block lists those cells ([source, target] pairs), the widened_sources and widened_targets, and moved[]: each widened location's role, index, requested point, the snapped point the filled cells really start or end at, and the distance_m between them| Field | Type | Required | Description |
|---|---|---|---|
| distances | number[][] | no | Metres, distances[source][target]; null where no route was
found. |
| durations | number[][] | no | Seconds, durations[source][target]; null where no route was
found. |
| engine | string | no | The routing engine that answered. |
| eta_calibration | object | no | The typical-delay calibration applied to the durations, with the
engine's own durations kept in engine_durations. |
| snap_retry | object | no | Present when the widened-snap retry produced the matrix. |
Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /matrix, Trafalgar Square to St Paul's and Westminster by car; lists trimmed to their first items
{
"distances": [
[
2477,
1594
]
],
"durations": [
[
413.753,
302.648
]
],
"engine": "valhalla",
"eta_calibration": {
"applied": true,
"cells_calibrated": 2,
"cells_not_walked": 0,
"cells_unchanged": 0,
"engine_durations": [
[
297,
231
]
],
"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. engine_durations holds the engine's own times.",
"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"
]
}
}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 (SN_ENGINE_MAX_MATRIX_DISTANCE_M; 400 km by default, 1,500 km on the hosted gateway; not chunkable around). The span refusal names the offending pair as furthest_pair: {source_index, target_index} and carries max_span_km, span_km, limit_env, engine_setting and self_host_docsapplication/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
request-timeout)application/problem+json · Problem
Error bodies follow the shared problem model documented on API conventions.
Also under Matrix
Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_matrix