## Optimize route through waypoints `optimize.create(**kwargs) -> OptimizeResult` **post** `/api/v1/optimize` Optimize route through waypoints ### Parameters - `waypoints: GeoJsonGeometry` Waypoints to visit (GeoJSON MultiPoint geometry, minimum 2 points) - `coordinates: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]` GeoJSON coordinates array (nesting depth varies by geometry type) - `Array[Float]` - `Array[Array[Float]]` - `Array[Array[Array[Float]]]` - `Array[Array[Array[Array[Float]]]]` - `type: :Point | :LineString | :Polygon | 3 more` - `:Point` - `:LineString` - `:Polygon` - `:MultiPoint` - `:MultiLineString` - `:MultiPolygon` - `mode: :auto | :foot | :bicycle` Travel mode (default: auto) - `:auto` - `:foot` - `:bicycle` - `roundtrip: bool` Whether route returns to start (default: true) ### Returns - `OptimizeResult = OptimizeCompletedResult | OptimizeProcessingResult` Optimization response — either a completed GeoJSON Feature route or an async job reference - `class OptimizeCompletedResult` Completed optimization — GeoJSON Feature with optimized route - `geometry: GeoJsonGeometry` - `coordinates: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]` GeoJSON coordinates array (nesting depth varies by geometry type) - `Array[Float]` - `Array[Array[Float]]` - `Array[Array[Array[Float]]]` - `Array[Array[Array[Array[Float]]]]` - `type: :Point | :LineString | :Polygon | 3 more` - `:Point` - `:LineString` - `:Polygon` - `:MultiPoint` - `:MultiLineString` - `:MultiPolygon` - `properties: { distance, duration, waypoint_order}` - `distance: Float` Total distance in meters - `duration: Float` Estimated duration in seconds - `waypoint_order: Array[Integer]` Optimized waypoint ordering - `status: :completed` Job status - `:completed` - `type: :Feature` - `:Feature` - `class OptimizeProcessingResult` Async optimization in progress — poll with the job_id - `job_id: String` Job ID for polling - `status: :processing` Job status - `:processing` ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) optimize_result = plaza.optimize.create(waypoints: {coordinates: [0], type: :Point}) puts(optimize_result) ```