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

POST/trace_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 50 shape points or 300 encoded-polyline characters, whichever is more. Class: standard, or premium for truck and ADR work. Published as unit_rules.trace in /pricing.json.
PremiumWhen the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true

What it does

Map matching to a route.

An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: 1 call per started block of 50 shape points or 300 encoded-polyline characters, whichever is more.

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/trace_route" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d '{"costing":"auto","shape":[{"lat":51.5074,"lon":-0.1278},{"lat":51.509,"lon":-0.13}],"shape_match":"map_snap"}'

Request body

application/json

Valhalla trace request JSON: shape (points) or encoded_polyline, costing, optional shape_match and costing_options

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

json
{
  "costing": "auto",
  "shape": [
    {
      "lat": 51.5074,
      "lon": -0.1278
    },
    {
      "lat": 51.509,
      "lon": -0.13
    }
  ],
  "shape_match": "map_snap"
}

Responses

200Valhalla route response for the matched trace
FieldTypeRequiredDescription
alternatesobject[]noAlternative matches, when the engine returns any.
tripobjectnoThe Valhalla trip along the matched path, shaped as on POST /route.

Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /trace_route with the request example; lists trimmed to their first items

json
{
  "trip": {
    "language": "en-US",
    "legs": [
      {
        "maneuvers": [
          {
            "begin_shape_index": 0,
            "begin_street_names": [
              "Trafalgar Square",
              "A4"
            ],
            "end_shape_index": 19,
            "instruction": "Drive northwest on Trafalgar Square/A4. Continue on A4.",
            "length": 0.164,
            "street_names": [
              "A4"
            ],
            "time": 20.728,
            "travel_mode": "drive",
            "travel_type": "car",
            "type": 1,
            "verbal_multi_cue": true,
            "verbal_post_transition_instruction": "Continue on A4 for 200 meters.",
            "verbal_pre_transition_instruction": "Drive northwest on Trafalgar Square, A4. Then, in 200 meters, Turn right onto Cockspur Street.",
            "verbal_succinct_transition_instruction": "Drive northwest. Then, in 200 meters, Turn right onto Cockspur Street."
          },
          {
            "begin_shape_index": 19,
            "end_shape_index": 26,
            "instruction": "Turn right onto Cockspur Street.",
            "length": 0.036,
            "street_names": [
              "Cockspur Street"
            ],
            "time": 5.7,
            "travel_mode": "drive",
            "travel_type": "car",
            "type": 10,
            "verbal_multi_cue": true,
            "verbal_post_transition_instruction": "Continue for 40 meters.",
            "verbal_pre_transition_instruction": "Turn right onto Cockspur Street. Then Bear right onto Pall Mall East.",
            "verbal_succinct_transition_instruction": "Turn right. Then Bear right onto Pall Mall East.",
            "verbal_transition_alert_instruction": "Turn right onto Cockspur Street."
          }
        ],
        "shape": "qdwfaB|_yF{AnCyA|Dk@pCc@`EYrGOhFOhFKdCIhBIhAg@`Cs@jBWtIc@dJ}ArWWlEGhAWnFaAnP}AlAaAr@cAF{@RaAJgAMuDgBgCqJqGmU}BnByNtM{T`KQyA_BkO",
        "summary": {
          "cost": 113.845,
          "has_ferry": false,
          "has_highway": false,
          "has_toll": false,
          "length": 0.348,
          "max_lat": 51.508881,
          "max_lon": -0.128015,
          "min_lat": 51.507289,
          "min_lon": -0.130368,
          "time": 51.01
        }
      }
    ],
    "locations": [
      {
        "lat": 51.5074,
        "lon": -0.1278,
        "original_index": 0,
        "type": "break"
      },
      {
        "lat": 51.509,
        "lon": -0.13,
        "original_index": 1,
        "type": "break"
      }
    ],
    "status": 0,
    "status_message": "Found route between points",
    "summary": {
      "cost": 113.845,
      "has_ferry": false,
      "has_highway": false,
      "has_toll": false,
      "length": 0.348,
      "max_lat": 51.508881,
      "max_lon": -0.128015,
      "min_lat": 51.507289,
      "min_lon": -0.130368,
      "time": 51.01
    },
    "units": "kilometers"
  }
}
400Invalid request

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_trace_route