## Optimize route through waypoints **post** `/api/v1/optimize` Optimize route through waypoints ### Body Parameters - `waypoints: GeoJsonGeometry` Waypoints to visit (GeoJSON MultiPoint geometry, minimum 2 points) - `coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number` GeoJSON coordinates array (nesting depth varies by geometry type) - `array of number` - `array of array of number` - `array of array of array of number` - `array of array of array of array of number` - `type: "Point" or "LineString" or "Polygon" or 3 more` - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `mode: optional "auto" or "foot" or "bicycle"` Travel mode (default: auto) - `"auto"` - `"foot"` - `"bicycle"` - `roundtrip: optional boolean` Whether route returns to start (default: true) ### Returns - `OptimizeResult = OptimizeCompletedResult or OptimizeProcessingResult` Optimization response — either a completed GeoJSON Feature route or an async job reference - `OptimizeCompletedResult = object { geometry, properties, status, type }` Completed optimization — GeoJSON Feature with optimized route - `geometry: GeoJsonGeometry` - `coordinates: array of number or array of array of number or array of array of array of number or array of array of array of array of number` GeoJSON coordinates array (nesting depth varies by geometry type) - `array of number` - `array of array of number` - `array of array of array of number` - `array of array of array of array of number` - `type: "Point" or "LineString" or "Polygon" or 3 more` - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: object { distance, duration, waypoint_order }` - `distance: optional number` Total distance in meters - `duration: optional number` Estimated duration in seconds - `waypoint_order: optional array of number` Optimized waypoint ordering - `status: "completed"` Job status - `"completed"` - `type: "Feature"` - `"Feature"` - `OptimizeProcessingResult = object { job_id, status }` Async optimization in progress — poll with the job_id - `job_id: string` Job ID for polling - `status: "processing"` Job status - `"processing"` ### Example ```http curl https://plaza.fyi/api/v1/optimize \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $PLAZA_API_KEY" \ -d '{ "waypoints": { "coordinates": [ 0 ], "type": "Point" } }' ```