## Optimize route through waypoints `client.optimize.create(OptimizeCreateParamsbody, RequestOptionsoptions?): OptimizeResult` **post** `/api/v1/optimize` Optimize route through waypoints ### Parameters - `body: OptimizeCreateParams` - `waypoints: GeoJsonGeometry` Waypoints to visit (GeoJSON MultiPoint geometry, minimum 2 points) - `coordinates: Array | Array> | Array>> | Array>>>` GeoJSON coordinates array (nesting depth varies by geometry type) - `Array` - `Array>` - `Array>>` - `Array>>>` - `type: "Point" | "LineString" | "Polygon" | 3 more` - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `mode?: "auto" | "foot" | "bicycle"` Travel mode (default: auto) - `"auto"` - `"foot"` - `"bicycle"` - `roundtrip?: boolean` Whether route returns to start (default: true) ### Returns - `OptimizeResult = OptimizeCompletedResult | OptimizeProcessingResult` Optimization response — either a completed GeoJSON Feature route or an async job reference - `OptimizeCompletedResult` Completed optimization — GeoJSON Feature with optimized route - `geometry: GeoJsonGeometry` - `coordinates: Array | Array> | Array>> | Array>>>` GeoJSON coordinates array (nesting depth varies by geometry type) - `Array` - `Array>` - `Array>>` - `Array>>>` - `type: "Point" | "LineString" | "Polygon" | 3 more` - `"Point"` - `"LineString"` - `"Polygon"` - `"MultiPoint"` - `"MultiLineString"` - `"MultiPolygon"` - `properties: Properties` - `distance?: number` Total distance in meters - `duration?: number` Estimated duration in seconds - `waypoint_order?: Array` Optimized waypoint ordering - `status: "completed"` Job status - `"completed"` - `type: "Feature"` - `"Feature"` - `OptimizeProcessingResult` Async optimization in progress — poll with the job_id - `job_id: string` Job ID for polling - `status: "processing"` Job status - `"processing"` ### Example ```typescript import Plaza from '@plazafyi/sdk'; const client = new Plaza({ apiKey: process.env['PLAZA_API_KEY'], // This is the default and can be omitted }); const optimizeResult = await client.optimize.create({ waypoints: { coordinates: [0], type: 'Point' }, }); console.log(optimizeResult); ```