POST /v1/stations/enrich-distances
Required preparation step before /v1/optimize. Takes a route and a list of stations, returns the same stations augmented with miles_from_route_start (how far along the route the station sits) and detour_minutes (how much extra driving time the detour adds).
Two filter stages eliminate stations that wouldn’t be useful:
- Coordinate pre-filter drops stations more than
coarse_filter_radius_milesfrom the route. Cheap; no API calls. Default 7 miles, range 5-20. - Detour threshold drops stations whose round-trip detour exceeds
max_detour_minutes. Default 10 minutes, range 1-20.
Partner-provided fields (id, price_per_gallon, brand, metadata, etc.) are preserved unchanged — only the two computed fields are added.
Returns warnings reporting how many stations were dropped at each stage.
/v1/stations/enrich-distances endpoint takes a route and a list of stations, returning the same stations with miles_from_route_start and detour_minutes populated for each station that passes the filter thresholds.
When to Use
Required before/v1/optimize if your station data doesn’t already include route-relative distances. If you compute these values in your own systems, you can skip this endpoint and pass enriched stations directly to /v1/optimize.
Filters
Two filters control which stations are returned:- Coarse radius filter (
coarse_filter_radius_miles, default 7): stations farther than this from the route polyline are dropped without matrix routing calls. Reduces cost. - Max detour filter (
max_detour_minutes, default 10): stations whose round-trip detour exceeds this threshold are dropped after matrix routing.
Behavior
- Partner-provided IDs and metadata are preserved unchanged in the response
- Stations dropped by filters are excluded from the response (not returned with null values)
- The response includes a count of stations dropped at each filter stage for debugging
Authorizations
Body
Internal route representation. Flat shape — upstream adapters normalize Google/Mapbox responses into this before it hits B2B code.
1 - 5000 elementsStations more than this many miles from the route polyline are dropped before the (expensive) distance matrix call. Bounds protect against runaway matrix costs. Increase for more lenient inclusion if your station coordinates are loose; decrease to cut matrix-call costs.
5 <= x <= 20Stations whose round-trip detour exceeds this many minutes are dropped after the matrix call.
1 <= x <= 20