# Why this route: rationale derived by route divergence

Add `"rationale": true` to a `POST /route` request on `https://api.mapmap.ai` and the response gains a `rationale` block naming the declared constraints or preferences that actually changed the route, the point where the alternative parts ways from it, and what each one costs in time and distance. The explanation is computed by re-routing with those declarations relaxed and diffing the geometry, so the engine derives it rather than a language model narrating a polyline after the fact. It covers the `truck`, `auto`, `bicycle`, `pedestrian` and `motor_scooter` costings. A rationale call is metered by the engine computations it actually performs, one call of its price class per computation: the route itself, plus the probe re-routes the explanation runs. That is at most 8 and typically fewer. A request with nothing to probe costs 1. A request whose declarations turn out not to have changed the route costs 2, because it stops after the first probe. Only a truck declaring all six constraints reaches 8. The price per unit is unchanged; the number of units follows the work, and every response reports the figure it was charged in a `rationale.metering` block so you can check it rather than take it on trust.

## What does `rationale: true` actually return?

It returns a `rationale` object alongside the normal route response, with a `method`, an `avoided[]` array and a `caveats` string. Here is a real request, a bicycle route across the Chilterns declaring a strong dislike of hills:

```bash
curl -X POST https://api.mapmap.ai/route \
  -H "Authorization: Bearer $SN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "locations": [
      { "lat": 51.5072, "lon": -0.1276 },
      { "lat": 52.4862, "lon": -1.8904 }
    ],
    "costing": "bicycle",
    "costing_options": { "bicycle": { "use_hills": 0.1 } },
    "rationale": true
  }'
```

The response shape, which is what an agent plans against:

```json
{
  "trip": { "…": "the normal route response, untouched" },
  "rationale": {
    "method": "route_divergence",
    "avoided": [{
      "kind": "hill_avoided",
      "constraint": "use_hills",
      "value": 0.1,
      "unit": null,
      "basis": "route_divergence",
      "baseline": "engine_default",
      "location": [-1.2431, 51.9911],
      "divergence": {
        "start": [-1.2431, 51.9911],
        "end": [-1.4102, 52.1408],
        "length_m": 23410
      },
      "time_saved_s": 380,
      "distance_saved_m": 2900,
      "reason": "the declared routing preference use_hills 0.1 changed the route here: …"
    }],
    "caveats": "…"
  }
}
```

`location` and both ends of `divergence` are GeoJSON-ordered `[lon, lat]`. `time_saved_s` and `distance_saved_m` are what the alternative would have saved, floored at zero. When nothing was binding, `avoided` is empty and a `note` says why in words, rather than the block quietly returning nothing. The MCP `route` tool takes the same flag and returns the same block, so an agent gets a route and its reasons in one call.

## How can an explanation be derived rather than written?

Because the comparison is real routing, not language. The routing engine exposes no exclusion set: there is no field anywhere in the response that says "this route avoided the 3.9 m bridge on the A40". So the gateway re-routes with the declared fields relaxed and compares the two shapes. Where the relaxed route takes a different way, that field provably changed the route, and the diverging span says exactly where.

The loop is deliberately small. One probe relaxes every declared field at once. If the route does not move, nothing was binding and the block says so honestly rather than inventing a reason. If it does move, one further probe per declared field attributes the divergence to individual fields. Shapes are compared with a 25 m per-point tolerance, which absorbs snapping jitter without hiding a real difference. Fields that only bind in combination are reported as a single entry with `kind: "combined"` and a `fields` array, rather than guessed apart.

We did not build the other version of this feature, the one where an LLM reads the polyline and writes a plausible paragraph about why. That version has no failure mode you can detect from the outside: it is equally fluent when it is right and when it is wrong. This one can only claim what a second routing call demonstrated.

## Which declarations can each costing explain?

Each costing has its own vetted table of relaxable fields, and only those produce a typed reason kind:

| Costing | Kinds |
|---|---|
| `truck` | `max_height`, `max_width`, `max_length`, `max_weight`, `hazmat`, `adr_tunnel` |
| `auto` | `highway_avoided`, `toll_avoided`, `ferry_avoided`, `living_street_avoided` |
| `bicycle` | `hill_avoided`, `surface_avoided`, `road_avoided`, `ferry_avoided`, `living_street_avoided` |
| `pedestrian` | `unlit_street_avoided`, `hiking_difficulty_limited`, `ferry_avoided`, `living_street_avoided`, `access_profile` |
| `motor_scooter` | `hill_avoided`, `primary_road_avoided`, `toll_avoided`, `ferry_avoided` |
| any | `combined` |

For a truck, the declared fields are the vehicle profile itself, which is the same `adr` object that drives [dimensional and ADR costing](/news/truck-routing-dimensions). For the others they are the avoidance-side routing preferences: `use_hills`, `use_tolls`, `use_lit`, `avoid_bad_surfaces`, `max_hiking_difficulty` and the rest.

## Why does the baseline differ by field type?

Because relaxing a field the wrong way makes the probe lie. Every entry carries a `baseline` naming what it was compared against:

| Field type | Relaxed to | `baseline` |
|---|---|---|
| Truck constraints (`height`, `weight`, `hazmat`, `adr_tunnel_code`) | explicitly non-binding values, a zero-size vehicle and an unrestricted tunnel code, never removed, because removal re-imposes engine defaults that can themselves bind | `relaxed_to_non_binding` |
| Preference factors (`use_hills`, `use_tolls`, `use_lit`) | removed, so the engine default applies, because relaxing to an extreme lets the probe's own bias masquerade as divergence | `engine_default` |
| Hard caps (`max_hiking_difficulty`) | their explicit maximum, 6 | `cap_lifted` |

## Live incidents are context, never a cause

Where the gateway has an incident source configured, the block also carries `context.incidents`: currently active incidents whose geometry overlaps the route corridor, each with its road, severity and cause, plus the source's coverage note and licence. They are attached as data next to the explanation and they are never an attributed cause, because the route did not avoid them.

There is deliberately no `traffic_delay_avoided` kind and no `incident_avoided` kind, and no delay figure is attached to an incident in this block. Where a source publishes its own delay, `POST /v1/incidents/along` passes it through unchanged; the rationale drops it, because here it would read as our claim about your route. Live traffic speeds do shape time-dependent routes and arrival times on England's strategic road network, but traffic is not a declared, relaxable field of the request, so the divergence probe has nothing to relax and no divergence can honestly be attributed to it, and a minutes-lost number for an incident would be a fabrication. An empty incidents array means no matched incident inside the configured sources' coverage, not a clear road. When no source is configured the field is absent entirely, because an empty list would itself be a claim.

## What it costs and what it cannot explain

The flag changes your bill, and it changes it by the work it did rather than by a flat surcharge. A `POST /route` with `rationale: true` is metered one unit of its price class per engine computation: the route itself, plus the all-relaxed probe, plus one probe per declared field where those run. The per-unit price is unchanged. The price class still follows the costing, so truck routing or a top-level `adr` object is Premium at 1p per unit and everything else is Standard at 0.05p, both from the 50,001st call of the month, per [pricing.json](/pricing.json). Included volume is denominated in standard calls, and the weights multiply, so a truck rationale call that ran three computations draws 60 included calls rather than 20.

The ceiling is 8 and most calls sit well under it. A request with nothing to probe draws 1. A request whose declarations turn out not to have changed the route draws 2, because it stops after the first probe. Only a truck declaring all six constraints reaches 8. The call is admitted against the ceiling its own body implies and the unused part is returned before the response is sent, so you are never charged for probes that did not run, and the figure charged comes back in the `rationale.metering` block and on the `x-mapmap-rationale-computations` header so it can be checked rather than trusted.

It is still an audit tool rather than a default. The per-field probes run concurrently, so the added latency is a fraction of the probe count, but the work is real. Ask for it when a human or an agent needs the reason, not on every request in a navigation session. If a probe fails, the block degrades to a `note` and the primary route is returned regardless: a route is never failed by its own explanation.

The harder limit is what the method can prove. Route divergence shows that a declared field was binding and where the two routes part ways. It does not identify the physical restriction or feature that caused it: not the specific signed bridge, not the particular hill, not the individual unlit street. The `value` in an entry is your declared value, never the infrastructure limit.

That boundary has consequences worth stating plainly:

- **It explains your declarations, not the map.** Nothing is attributed unless you declared it. A road missing from the graph entirely, or a restriction nobody has modelled, cannot appear as a reason, because relaxing your declaration will not make the engine consider a road it does not know exists. Routing derives from OpenStreetMap, so the graph's blind spots are the rationale's blind spots.
- **Only avoidance-side declarations are attributed.** A preference that seeks something rather than avoids it is skipped, because an avoidance vocabulary cannot honestly describe it. So is any value sitting at or on the permissive side of the engine default, which could not have diverged anything.
- **`bus` and `motorcycle` return no rationale.** They have no vetted preference table yet, and the block returns an empty `avoided[]` with a note naming the costing rather than guessing at one.

Every entry carries `basis: "route_divergence"` and the block repeats these limits in its own `caveats` string, so an agent relaying the explanation to a user relays the epistemics with it.

## Try it

The request and response shapes above are specified in the "Why this route" section of the [API reference](/docs/api-reference), including the full kind table and the baseline rules. The engine doing the re-routing is the one we describe in [why we built our own routing engine](/news/why-our-own-routing-engine), and the instructions it hands back are covered in [turn-by-turn instructions](/news/turn-by-turn-instructions). Issue a key with one card-free call and add `"rationale": true` to a route you already run.
