Skip to content
Documentation menu
docs / api / post-route-report
Routing

POST/route/report

Access and price

AuthAn API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Needs a full key; a browser (maps) key is refused.
Price1 call per request. Class: standard, or premium for truck and ADR work. Published as unit_rules.default in /pricing.json.
PremiumWhen the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true

What it does

Distance and duration of a route or trace broken down by road class, administrative area, toll, bridge, tunnel and surface.

An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: 1 call per request.

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/route/report" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"costing":"truck","costing_options":{"truck":{"height":4,"weight":40}},"shape":[{"lat":51.50748,"lon":-0.12796},{"lat":51.5065,"lon":-0.14335},{"lat":51.50074,"lon":-0.16209},{"lat":51.49511,"lon":-0.18124},{"lat":51.49214,"lon":-0.20101},{"lat":51.49121,"lon":-0.22201},{"lat":51.49052,"lon":-0.24375},{"lat":51.48757,"lon":-0.26428},{"lat":51.4918,"lon":-0.28295}]}'

Request body

application/json

Either {"locations": [{lat,lon}, …], "costing": "auto"} (route mode: computes the route internally) or {"shape": [{lat,lon}, …]} / {"encoded_polyline": "…"} (trace mode: reports over an existing trace); exactly one of locations or shape/encoded_polyline. Optional costing_options

Example: From website/public/docs/analysis.md:610

json
{
  "costing": "truck",
  "costing_options": {
    "truck": {
      "height": 4,
      "weight": 40
    }
  },
  "shape": [
    {
      "lat": 51.50748,
      "lon": -0.12796
    },
    {
      "lat": 51.5065,
      "lon": -0.14335
    },
    {
      "lat": 51.50074,
      "lon": -0.16209
    },
    {
      "lat": 51.49511,
      "lon": -0.18124
    },
    {
      "lat": 51.49214,
      "lon": -0.20101
    },
    {
      "lat": 51.49121,
      "lon": -0.22201
    },
    {
      "lat": 51.49052,
      "lon": -0.24375
    },
    {
      "lat": 51.48757,
      "lon": -0.26428
    },
    {
      "lat": 51.4918,
      "lon": -0.28295
    }
  ]
}

Responses

200{distance_m, duration_s, by_road_class: {<class>: {distance_m, duration_s, edge_count}}, by_admin: [{country_code, country_text, state_code, state_text, distance_m, duration_s, edge_count}], toll: {edge_count, distance_m}, bridge: {…}, tunnel: {…}, by_surface: {<surface>: {distance_m, edge_count}}, edge_count}. Distances in metres, durations in seconds. An edge with no resolvable admin area is grouped under a null-keyed entry in by_admin, never guessed at
FieldTypeRequiredDescription
bridgeobjectnoDistance and edge count on bridges.
by_adminobject[]noDistance, time and edge count per country and state.
by_road_classobjectnoDistance, time and edge count per road class (motorway, trunk, primary, residential and so on).
by_surfaceobjectnoDistance and edge count per surface class.
distance_mnumbernoTotal length, metres.
duration_snumbernoTotal time, seconds.
edge_countintegernoNumber of road edges matched.
tollobjectnoDistance and edge count on toll roads.
tunnelobjectnoDistance and edge count in tunnels.

Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /route/report with the request example's shape, by car; lists trimmed to their first items

json
{
  "bridge": {
    "distance_m": 1149,
    "edge_count": 5
  },
  "by_admin": [
    {
      "country_code": "GB",
      "country_text": "United Kingdom",
      "distance_m": 11891,
      "duration_s": 1062.4,
      "edge_count": 216,
      "state_code": "ENG",
      "state_text": "England"
    }
  ],
  "by_road_class": {
    "motorway": {
      "distance_m": 486,
      "duration_s": 36.5,
      "edge_count": 2
    },
    "primary": {
      "distance_m": 1949,
      "duration_s": 231.1,
      "edge_count": 54
    },
    "residential": {
      "distance_m": 448,
      "duration_s": 66.3,
      "edge_count": 20
    },
    "trunk": {
      "distance_m": 9008,
      "duration_s": 728.5,
      "edge_count": 140
    }
  },
  "by_surface": {
    "paved_smooth": {
      "distance_m": 11891,
      "edge_count": 216
    }
  },
  "distance_m": 11891,
  "duration_s": 1062.4,
  "edge_count": 216,
  "toll": {
    "distance_m": 0,
    "edge_count": 0
  },
  "tunnel": {
    "distance_m": 313,
    "edge_count": 1
  }
}
400Invalid request, or neither/both of locations and a trace given

application/problem+json · Problem

401Missing or invalid API key. Also: No key, or a missing, malformed, unknown, revoked or expired one (unauthorized); the body carries signup, docs and a one-call hint for a free key

application/problem+json · Problem

402Beyond the included volume with no way to pay this call: an x402 body naming how to pay (provisional key past its allowance, prepaid balance below the price, or a rejected X-PAYMENT). Not problem+json

application/json · X402PaymentRequired

403The key may not call this: a browser key outside its scope (scope-insufficient), a request from an origin the key does not allow (origin-not-allowed), or an account restriction (forbidden)

application/problem+json · Problem

413The request declares a body larger than 1048576 bytes (plain text, not problem+json)

text/plain

429Quota or rate limit exceeded. Also: Per-key rate limit (rate-limited, with Retry-After), or monthly quota exhausted with no payment path (quota-exceeded)

application/problem+json · Problem

502Upstream routing engine failed

application/problem+json · Problem

504The request did not finish within the gateway's request deadline (request-timeout)

application/problem+json · Problem

Error bodies follow the shared problem model documented on API conventions.

Also under Routing

Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_route_report