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

POST/route

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 started block of 20 waypoints (2 to 20 waypoints is 1 call). With rationale: true, one call of its class per engine computation it performs, at most 8. Class: standard, or premium for truck and ADR work. Published as unit_rules.route_waypoints in /pricing.json.
PremiumWhen the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true

What it does

A route for any profile, with Valhalla-shaped request and response bodies and the adr dangerous-goods extension.

An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: 1 call per started block of 20 waypoints (2 to 20 waypoints is 1 call). With rationale: true, one call of its class per engine computation it performs, at most 8.

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/route" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"costing":"auto","locations":[{"lat":51.5072,"lon":-0.1276},{"lat":52.4862,"lon":-1.8904}]}'

Request body

application/json

Valhalla RouteRequest JSON (costing may be auto, truck, bicycle, pedestrian, motor_scooter, bus or motorcycle; per-mode costing_options such as pedestrian use_lit/type/max_hiking_difficulty or bicycle bicycle_type/use_roads/use_living_streets/avoid_bad_surfaces/use_hills pass through), optionally extended with top-level avoid and exclude string arrays naming road features to keep off; avoid accepts tolls, highways and ferries and is a PREFERENCE (the engine's use_* factor set to 0, which its own reference says is not guaranteed to avoid them entirely); exclude accepts tolls, highways, ferries, bridges and tunnels and is a HARD exclusion that can answer "no path" and that depends on the routing engine's service_limits.allow_hard_exclusions setting. Both are validated per costing, so a value the engine has no field for is a 400 naming the supported set rather than a silently ignored option, and every response that used either carries a top-level avoid block echoing what was applied. Kerbside arrival uses each location's own preferred_side (same/opposite/either, aliases curb/unrestricted; resolved against the locale's driving side) with street_side_tolerance, street_side_max_distance and street_side_cutoff, optionally extended with a top-level adr vehicle profile object, a top-level truck object accepted as an alias for costing_options.truck on truck costing (merged before the search; a field declared in both places with different values is a 400 naming it, and a top-level truck object on any other costing is a 400), and a top-level rationale: true flag (truck, auto, bicycle, pedestrian and motor_scooter; opt-in because it costs up to 1 + N extra engine calls, and it draws one call of its class per engine computation it performs, at most 8 and typically fewer, reported back in rationale.metering) for a structured rationale.avoided[] block derived by route divergence, with live incidents on the route attached as context where incident data is configured, and a top-level landmarks: true flag for turn instructions anchored to recognisable places ("Turn right just after the Shell garage"), added alongside each manoeuvre's own instruction as landmark_instruction and never replacing it, and a top-level traffic: true flag for a per-leg traffic object (covered_pct, confidence in HERE's bands, sources) saying what speed data stood behind the ETA, plus, only when a live claim stands (date_time.type 0 and a fresh snapshot), a congestion object: direction-matched spans graded moderate, slow or severe by live against typical speed with shape indices for colouring the line, delay_s (time lost against National Highways' own typical speeds on stretches with a live record, England strategic road network only) and live_m; computed from the returned geometry, so it costs no extra engine call and is not metered separately. May also carry an optional top-level emissions object (vehicle_category, fuel, euro_standard) declaring the vehicle for UK clean-air zone assessment, and a top-level avoid_zones: true flag asking the search to keep out of every zone that vehicle would be charged or banned in (applied as exclude_polygons before the route is computed, so no extra engine call and no extra metering). May also carry a top-level scenic extension (true, or an object with max_extra_minutes) on auto costing, which adds a scenic block saying whether a prettier route exists, what makes it prettier in one spoken-ready sentence measured from the basemap tiles, and how many extra minutes it costs. The route in trip is never changed by it: the scenic route rides alongside in scenic.alternative.trip. An offer that cannot state its reason is not made, and the flag draws at most two extra route computations, reserved up front and refunded to what was drawn. alternates with date_time type 0 (leave now) on an origin plus destination request (not truck costing) returns the live-aware route plus up to alternates distinct alternatives, each re-costed on its exact path with the same date_time so every duration uses live and predicted speeds where covered, sorted fastest first (trip is the fastest, save for the turnaround case below); billed as one route call, and if the alternatives cannot be costed the time-dependent route comes back alone. Any other date_time type, or a multi-stop request, returns one route when a date_time is set, because the engine's time-dependent search has no alternates. For auto, motorcycle and motor_scooter, when the engine's first choice turns off a road and comes straight back onto it, two same-side turns at most 50 m apart that turn the car round (a turnaround loop through a slip or side road, which the engine prices as two ordinary turns), and an alternate in the same response costs at most 120 s more, that alternate becomes trip, the looping route stays in alternates, and a top-level turnaround block gives loop_at, road, seconds_added and threshold_s. No extra engine call and no extra metering; without alternates nothing changes. Pedestrian routes also accept costing_options.pedestrian.use_hills (0 to 1; a wheelchair route that omits it is sent 0), max_grade_pct (whole percent 1 to 90, mapped onto the engine's max_grade, which the engine accepts and does not enforce yet: the response says so in grade.cap) and surface_quality ("avoid" or "ignore", wheelchair only), plus a top-level grade_report: true flag for the grade block (automatic on wheelchair routes and whenever a grade cap is set). At most 500 locations (waypoints) per request. The routing engine takes 20 per call, so longer lists are cut at break waypoints, routed concurrently and spliced into one continuous route, and billed one call per started block of 20 waypoints. When the first search finds no path (engine NoRoute, error 442) the gateway searches once more with a wider snap (radius 1000 m, minimum_reachability 500) at every location that did not set its own, keeping every value the caller did set (radius: 0 stays 0), and the answer then carries a top-level snap_retry block. The retry is never sent when the request carries exclude_locations or exclude_polygons (including avoid_zones rings): a wider snap would move a location onto the nearest open road and route round the exclusion, so the honest no-path answer stands. A top-level snap_retry: false turns the retry off

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

json
{
  "costing": "auto",
  "locations": [
    {
      "lat": 51.5072,
      "lon": -0.1276
    },
    {
      "lat": 52.4862,
      "lon": -1.8904
    }
  ]
}

Responses

200Valhalla route response, with an adr echo when an ADR profile was applied, a rationale block when requested (avoided[] entries carry basis: "route_divergence"; see the module docs for the method's honesty limits), and, when landmarks was requested, a landmark_instruction on each manoeuvre where a recognisable place cleared the salience bar plus a landmarks summary block reporting how many were annotated, and, when traffic was requested, a traffic object on each leg plus a top-level traffic summary carrying the route aggregate, the coverage snapshot's freshness and the method's caveats, and, when scenic was requested, a top-level scenic block with the chosen route, its stated reason, the measured features behind it, the extra minutes it costs and every candidate that was compared with why it lost, and, on a truck route on a deployment with a baked restriction grid, a top-level restriction_coverage receipt naming how many grid cells the route crosses, how they are graded for restriction-tagging density, how many fall outside the grid's own extent and what absence of a recorded restriction does not prove, and, when the route crosses a UK clean-air or low-emission zone (or avoid_zones was set), a top-level zones block naming each crossed zone, whether the declared vehicle is charged, banned or compliant there, the published daily charge with its source URL and checked date, and an estimated_charges total kept separate from every routing cost, and, when the gateway's road walk succeeded, on each manoeuvre speed_limit (in the trip's units) plus country (ISO 3166-1 alpha-2), subdivision (ISO 3166-2), ref (route numbers only, ; separated), road_class, speed_limit_unit (mph or km/h, the road's unit, never the request's), speed_limit_sign (vienna or mutcd) and speed_limit_posted ({"type":"known","value":30,"unit":"mph"}, unlimited or unknown, with "national": true for a GB national speed limit where the map records it) and driving_side (left or right, from the road's country), and, on a pedestrian wheelchair route where the deployment has a surface graph (or the request set surface_quality), a top-level surface_quality block saying whether the route was computed on the surface-quality graph (applied, with the region, the exact rule, the data timestamp and a caveat) or why not (reason: outside_coverage, opted_out, surface_graph_unavailable or not_configured), and, on a wheelchair route, a grade cap or grade_report: true, a top-level grade block with the maximum grade and total ascent and descent sampled every 10 m from the elevation model, the use_hills preference sent and whether a requested cap was enforced, and, when the widened-snap retry produced the route, a top-level snap_retry block: radius_m, minimum_reachability, widened_locations, moved[] (each widened location's requested point, the snapped point the route really starts or ends at and the distance_m between them) and discontinuities[] (a location where one leg ends and the next starts more than 1 m apart, with gap_m), and, when the request sent exclude_locations or exclude_polygons, a top-level exclusions block: threshold_m (5), locations[] (index, matched, way_ids and snapped_m: what the engine snapped each excluded location to, from one unmetered lookup run beside the route, all null with matched_unavailable when it could not run), passed[] (kind location or polygon, index, leg, distance_m: each exclusion a leg of trip comes within 5 m of, or whose polygon it enters; a distance check, not proof the route used an excluded road) and snap_retry_used
FieldTypeRequiredDescription
adrobjectnoThe echoed ADR (dangerous goods) declaration, on truck routes that carried one.
adr_tunnel_enforcementobjectnoWhat the ADR echo does and does not prove about tunnel categories, sent beside adr so it cannot be missed.
alternatesobject[]noAlternative routes, each { "trip": … }, when alternates was asked for and the engine found any.
avoidobjectnoWhat avoid and exclude became, and what a 200 does and does not prove. Present when either was asked for.
enginestringnoThe routing engine that answered, e.g. valhalla.
eta_calibrationobjectnoWhat MapMap's typical-delay calibration added to the engine's times and on what evidence (method, added_s, bands, period, sources, note). Present when it added something, so a route outside Great Britain is unchanged.
eta_capobjectnoWhat the HGV speed limiter did to the durations. Truck only, and absent with the cap off.
exclusionsobjectnoPresent when the request sent exclude_locations or exclude_polygons: threshold_m (5), locations[] (index, matched, way_ids, snapped_m: what the engine snapped each excluded location to, null with matched_unavailable when the lookup could not run), passed[] (kind location or polygon, index, leg, distance_m: each exclusion a leg of trip comes within 5 m of, or whose polygon it enters) and snap_retry_used.
gradeobjectnoThe hill report: pedestrian only, on grade_report: true, every wheelchair route and whenever a grade cap was asked for.
landmarksnot statednoLandmark-anchored turn instructions, on landmarks: true.
rationaleobjectnoThe why-this-route explanation, on rationale: true, with the route computations it was billed for.
restriction_coverageobjectnoHow well the area the route crosses is tagged for truck restrictions. Truck only, and only on a deployment with the restriction grid baked.
scenicobjectnoThe scenic block, on a scenic request.
snap_retryobjectnoPresent when the widened-snap retry produced this route: which locations were widened and where the route really starts and ends.
surface_qualityobjectnoSurface quality on a wheelchair route: whether it was computed on the surface graph and, if not, why.
trafficnot statednoThe traffic annotation of the returned geometry, on traffic: true.
tripobjectnoThe Valhalla trip: locations, legs (each with maneuvers, a precision-6 encoded shape and a summary), the trip summary (length in the requested units, time in seconds), units, language, status and status_message.
turnaroundobjectnoPresent when the engine's first choice was a turnaround loop and an alternate was promoted over it.
zonesobjectnoClean-air and low-emission zones on the returned geometry, with each zone's charge for the vehicle, the boundary source and caveats. Absent when the route crosses none and no avoidance was asked for.

Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /route, Trafalgar Square to St Paul's by car; lists trimmed to their first items

json
{
  "engine": "valhalla",
  "eta_calibration": {
    "added_s": 116.8,
    "alternates_added_s": [],
    "applied": true,
    "bands": {
      "built_up": {
        "added_s": 116.8,
        "distance_m": 2475.6
      }
    },
    "engine_time_s": 297.375,
    "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. 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, and the route itself is unchanged.",
    "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"
    ],
    "traffic_network_m": 0
  },
  "trip": {
    "language": "en-US",
    "legs": [
      {
        "maneuvers": [
          {
            "begin_shape_index": 0,
            "country": "GB",
            "driving_side": "left",
            "end_shape_index": 1,
            "instruction": "Drive east on Trafalgar Square/A4.",
            "length": 0.012,
            "ref": "A4",
            "road_class": "primary",
            "speed_limit": {
              "type": "known",
              "value": 32
            },
            "speed_limit_posted": {
              "type": "known",
              "unit": "mph",
              "value": 20
            },
            "speed_limit_sign": "vienna",
            "speed_limit_unit": "mph",
            "street_names": [
              "Trafalgar Square",
              "A4"
            ],
            "subdivision": "GB-ENG",
            "time": 2.013,
            "travel_mode": "drive",
            "travel_type": "car",
            "type": 3,
            "verbal_multi_cue": true,
            "verbal_post_transition_instruction": "Continue for 10 meters.",
            "verbal_pre_transition_instruction": "Drive east on Trafalgar Square, A4. Then Enter Charing Cross and take the 1st exit onto Trafalgar Square.",
            "verbal_succinct_transition_instruction": "Drive east. Then Enter Charing Cross and take the 1st exit onto Trafalgar Square."
          },
          {
            "begin_shape_index": 1,
            "country": "GB",
            "driving_side": "left",
            "end_shape_index": 3,
            "instruction": "Enter Charing Cross and take the 1st exit onto Trafalgar Square/A4.",
            "length": 0.008,
            "road_class": "primary",
            "roundabout_exit_count": 1,
            "speed_limit": {
              "type": "known",
              "value": 32
            },
            "speed_limit_posted": {
              "type": "known",
              "unit": "mph",
              "value": 20
            },
            "speed_limit_sign": "vienna",
            "speed_limit_unit": "mph",
            "street_names": [
              "Charing Cross"
            ],
            "subdivision": "GB-ENG",
            "time": 1.311,
            "travel_mode": "drive",
            "travel_type": "car",
            "type": 26,
            "verbal_pre_transition_instruction": "Enter Charing Cross and take the 1st exit onto Trafalgar Square, A4.",
            "verbal_succinct_transition_instruction": "Enter the roundabout and take the 1st exit.",
            "verbal_transition_alert_instruction": "Enter Charing Cross and take the 1st exit onto Trafalgar Square."
          }
        ],
        "shape": "{swfaBl_yF[gJWuBSsB}CoMs@eDwBiHu@{A}@cA}@_@eAMkBB{AJqQfDqGvB",
        "summary": {
          "cost": 599.436,
          "has_ferry": false,
          "has_highway": false,
          "has_toll": false,
          "length": 2.476,
          "max_lat": 51.514216,
          "max_lon": -0.098437,
          "min_lat": 51.507534,
          "min_lon": -0.128007,
          "time": 414.128
        }
      }
    ],
    "locations": [
      {
        "lat": 51.508,
        "lon": -0.1281,
        "original_index": 0,
        "side_of_street": "left",
        "type": "break"
      },
      {
        "lat": 51.5138,
        "lon": -0.0984,
        "original_index": 1,
        "type": "break"
      }
    ],
    "status": 0,
    "status_message": "Found route between points",
    "summary": {
      "cost": 599.436,
      "has_ferry": false,
      "has_highway": false,
      "has_toll": false,
      "length": 2.476,
      "max_lat": 51.514216,
      "max_lon": -0.098437,
      "min_lat": 51.507534,
      "min_lon": -0.128007,
      "time": 414.128
    },
    "units": "kilometers"
  },
  "zones": {
    "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.",
    "crossed": [
      {
        "assessment": "unknown",
        "boundary_note": "the authority publishes this zone in 24 parts; detection uses the largest, which covers 99.01% of the published area, so a route through one of the smaller parts alone is not detected",
        "boundary_simplified_tolerance_m": 1500,
        "boundary_source": {
          "checked": "2026-09-03",
          "licence": "Open Government Licence v2.0 (London Datastore record); boundary geometry taken from TfL's ULEZ layer under OGL v3.0; TfL Open Data: attribution \"Powered by TfL Open Data\" required wherever this geometry is shown",
          "publisher": "Greater London Authority / Transport for London",
          "url": "https://data.london.gov.uk/dataset/low-emission-zone-2kodd"
        },
        "currency": "GBP",
        "distance_in_zone_m": 2476,
        "enforcement": "charge",
        "entry_arc_m": 0,
        "exit_arc_m": 2476,
        "explanation": "London Low Emission Zone: charge depends on vehicle emissions, supply `emissions` (vehicle_category, fuel, euro_standard) to resolve",
        "hours": "24 hours a day, every day of the year",
        "id": "gb-london-lez",
        "name": "London Low Emission Zone",
        "operator": "Transport for London",
        "penalty": "£500 (£250 within 14 days) for the lighter classes; £1,000 (£500) for a heavy vehicle meeting Euro IV for particulates but not Euro VI; £2,000 (£1,000) for a heavy vehicle below Euro IV for particulates",
        "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",
        "boundary_note": "the authority publishes this zone in 24 parts; detection uses the largest, which covers 99.01% of the published area, so a route through one of the smaller parts alone is not detected",
        "boundary_simplified_tolerance_m": 1500,
        "boundary_source": {
          "checked": "2026-09-03",
          "licence": "Open Government Licence v3.0; TfL Open Data: attribution \"Powered by TfL Open Data\" required wherever this geometry is shown",
          "publisher": "Transport for London",
          "url": "https://gis-tfl.opendata.arcgis.com/datasets/ultra-low-emission-zone-ulez"
        },
        "currency": "GBP",
        "distance_in_zone_m": 2476,
        "enforcement": "charge",
        "entry_arc_m": 0,
        "exit_arc_m": 2476,
        "explanation": "London Ultra Low Emission Zone: charge depends on vehicle emissions, supply `emissions` (vehicle_category, fuel, euro_standard) to resolve",
        "hours": "24 hours a day, 7 days a week, every day of the year, except Christmas Day (25 December)",
        "id": "gb-london-ulez",
        "name": "London Ultra Low Emission Zone",
        "operator": "Transport for London",
        "penalty": "£180, reduced to £90 if paid within 14 days",
        "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"
      }
    ],
    "dataset": {
      "coverage": "United Kingdom",
      "generated": "2026-09-03",
      "version": 1
    },
    "estimated_charges": {
      "banned_zones": 0,
      "basis": "sum of each crossed zone's published daily charge for the declared vehicle, one charge per zone per day",
      "currency": "GBP",
      "daily_total": 0,
      "note": "2 crossed zones could not be resolved for this vehicle and are excluded from the total; read each entry's `explanation` for why",
      "unresolved_zones": 2
    },
    "note": "charge depends on vehicle emissions, supply `emissions` (vehicle_category, fuel, euro_standard) to resolve"
  }
}
400Invalid request, conflicting costing_options, more than 500 locations, or no path (engine error 442; with exclusions the detail says the snap was not widened)

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

422More waypoints than the routing engine takes in one call, AND the route cannot be split faithfully: a run of more than 20 consecutive through/via/break_through waypoints, a time-dependent route (date_time.type 0, 1 or 2), or a request for alternates. detail says which and what to change

application/problem+json · Problem

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