Optimize Multi-Stop Route
optimization_toolOptimize visiting order for up to 12 waypoints, solving the Traveling Salesman Problem to minimize travel time. Supports custom start, end, and roundtrip options.
Instructions
Find the optimal (shortest by travel time) route through a set of 2-12 coordinates. Solves the Traveling Salesman Problem to determine the best visiting order. Supports options for starting point, ending point, and whether to return to start.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| steps | No | Whether to include turn-by-turn instructions | |
| source | No | Location to start the trip. "any" allows any coordinate, "first" forces the first coordinate as start. | any |
| profile | No | Routing profile to use for optimization | mapbox/driving |
| language | No | Language for instructions (if steps=true). ISO 639-1 code (e.g., "en", "es"). | |
| overview | No | Detail level of route geometry | simplified |
| roundtrip | No | Whether to return to the starting point. Set to false for one-way trips. | |
| geometries | No | Format for route geometry | geojson |
| annotations | No | Additional metadata to include for each route segment | |
| coordinates | Yes | Array of {longitude, latitude} coordinate pairs to optimize a route through. The V1 API supports 2-12 coordinates and returns the optimal visiting order. | |
| destination | No | Location to end the trip. "any" allows any coordinate, "last" forces the last coordinate as end. | any |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Status code (e.g., "Ok" for success, error code otherwise) | |
| trips | Yes | Array containing the optimized trip (typically 1 trip for all waypoints) | |
| message | No | Error message if code is not "Ok" | |
| waypoints | Yes | Input coordinates snapped to the road network in optimized order |