The Route Optimization API assigns tasks and routes to a vehicle fleet, optimizing against the objectives and constraints you supply, such as time windows, vehicle capacity, driver hours, and costs. You call it through REST, gRPC, or client libraries, and it returns visit sequences, shipment assignments, estimated times, and route metrics.

## Route Optimization API: key facts

- **Product:** Route Optimization API
- **Also known as:** GMPRO
- **Category:** Routes
- **Platform:** Web service (REST)
- **Runs on:** Server (backend code)
- **Launch stage:** GA
- **Lifecycle:** Active
- **Overview:** [Route Optimization API overview](https://developers.google.com/maps/documentation/route-optimization/overview.md.txt)

## Route Optimization API: when to use it

**Use Route Optimization API when:**

- You need to assign shipments or tasks to several vehicles while respecting time windows, vehicle capacity, driver hours, and costs.
- You need the best stop sequence for one vehicle with several pickups, deliveries, or appointments.
- You need to re-optimize active routes for new orders (such as on-demand dispatch) using `injectedFirstSolutionRoutes` or `injectedSolutionConstraint`.
- You need route tokens for each leg of an optimized plan to pass to the Navigation SDK.
**Don't use Route Optimization API when:**

- You need live tracking of how drivers execute the plan; the API returns planned polylines, not real-time vehicle routes. Use [Fleet Engine Service](https://developers.google.com/maps/documentation/mobility/fleet-engine/quick-reference.md.txt) instead.
- You need in-app turn-by-turn guidance for drivers along the optimized route. Use [Navigation SDK for Android](https://developers.google.com/maps/documentation/navigation/android-sdk/quick-reference.md.txt) instead.
- You need in-app turn-by-turn guidance for drivers on iOS along the optimized route. Use [Navigation SDK for iOS](https://developers.google.com/maps/documentation/navigation/ios-sdk/quick-reference.md.txt) instead.

## Route Optimization API: setup

- **Service to enable:** `routeoptimization.googleapis.com`
- **Authentication:** OAuth 2.0, Service account
- **Get started:** [Set up Route Optimization API](https://developers.google.com/maps/documentation/route-optimization/cloud-setup.md.txt)
- **Reference:** [Route Optimization API reference](https://developers.google.com/maps/documentation/route-optimization/reference.md.txt)
- **Pricing:** [Route Optimization API usage and billing](https://developers.google.com/maps/documentation/route-optimization/usage-and-billing.md.txt)
- **Policies:** [Route Optimization API policies](https://developers.google.com/maps/documentation/route-optimization/policies.md.txt)
- **Release notes:** [Route Optimization API release notes](https://developers.google.com/maps/documentation/route-optimization/release-notes.md.txt)

**Official Route Optimization API packages:**

- npm: `@googlemaps/routeoptimization`
- pypi: `google-maps-routeoptimization`
- go: `cloud.google.com/go/maps`
- maven: `com.google.maps:google-maps-routeoptimization`

## Route Optimization API: related products

- **Often used with:** [Navigation SDK for Android](https://developers.google.com/maps/documentation/navigation/android-sdk/quick-reference.md.txt), [Navigation SDK for iOS](https://developers.google.com/maps/documentation/navigation/ios-sdk/quick-reference.md.txt), [Fleet Engine Service](https://developers.google.com/maps/documentation/mobility/fleet-engine/quick-reference.md.txt), [Maps JavaScript API](https://developers.google.com/maps/documentation/javascript/quick-reference.md.txt)

## Route Optimization API: common mistakes

- **Problem:** For REST calls to the blocking `OptimizeTours` endpoint, the default 60-second deadline overrides any request-body `timeout` larger than 60 seconds. **Fix:** Set the `X-Server-Timeout` header (seconds, no "s" suffix) to extend the deadline. Client libraries and gRPC default to 3600 seconds. See [/maps/documentation/route-optimization/timeouts](https://developers.google.com/maps/documentation/route-optimization/timeouts.md.txt).
- **Problem:** `timeout` and deadline values are capped at 1800 seconds. **Fix:** Set `allowLargeDeadlineDespiteInterruptionRisk` to `true` to allow up to 3600 seconds, accepting a higher risk of interruption errors. See [/maps/documentation/route-optimization/timeouts](https://developers.google.com/maps/documentation/route-optimization/timeouts.md.txt).
- **Problem:** Without cost parameters (for example `costPerHour` or `costPerKilometer`), the optimizer treats all solutions as equal. **Fix:** Define cost parameters on vehicles that reflect your business costs. See [/maps/documentation/route-optimization/make-first-request](https://developers.google.com/maps/documentation/route-optimization/make-first-request.md.txt).
- **Problem:** Requests authenticated with an API key fail; every request needs an OAuth token. **Fix:** Use an OAuth token with the `https://www.googleapis.com/auth/cloud-platform` scope, for example through Application Default Credentials or a service account. See [/maps/documentation/route-optimization/cloud-setup#create-an-oauth-token](https://developers.google.com/maps/documentation/route-optimization/cloud-setup.md.txt#create-an-oauth-token).

## What you can do with Route Optimization API

See the guides linked below for each task, or compare across products in the
[Capabilities Explorer](https://developers.google.com/maps/documentation/capabilities-explorer.md.txt).

- [Return a multi-stop delivery plan, optimized based on specified routing, cost, shipment, and vehicle constraints.](https://developers.google.com/maps/documentation/route-optimization/make-first-request.md.txt)
- [Return start and end times for each stop on an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/interpret-response.md.txt)
- [Return the travel, delay, break, and wait durations between each stop on an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/interpret-response.md.txt)
- [Return vehicle load information at each stop on an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/load-demands-limits.md.txt)
- [Return cost information for each shipment in an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/interpret-response.md.txt)
- [Return an encoded polyline for the route between each stop on an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/polylines-and-route-tokens.md.txt)
- [Return a navigation route token for the route between each stop on an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/polylines-and-route-tokens.md.txt)
- [Return aggregate shipment, vehicle, and cost metrics for an optimized delivery plan.](https://developers.google.com/maps/documentation/route-optimization/interpret-response.md.txt)
- [Specify the start and end time window for a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/concepts/time-windows.md.txt#structure)
- [Specify start and end time availability and locations for each vehicle in a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/make-first-request.md.txt#construct-request)
- [Specify vehicle time costs for each vehicle in a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/assignment.md.txt)
- [Specify cost model parameters for a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/cost-model.md.txt)
- [Specify pickup and delivery time constraints for each shipment in a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/time-windows.md.txt#scenario_1_delivering_within_time_windows)
- [Specify vehicle assignments for a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/make-first-request.md.txt)
- [Specify load limits for each vehicle in a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/load-demands-limits.md.txt)
- [Specify whether to consider live traffic information for a multi-stop delivery plan.](https://developers.google.com/maps/documentation/route-optimization/reference/rest/v1/projects/optimizeTours.md.txt)
- [Batch process a multi-stop delivery plan optimization request and write the response to Google Cloud Storage.](https://developers.google.com/maps/documentation/route-optimization/endpoints.md.txt#batchoptimizetours)
- [Reserve time for parking before making deliveries.](https://developers.google.com/maps/documentation/route-optimization/transition-attributes.md.txt)
- [Prioritize nearby visits to be made back to back.](https://developers.google.com/maps/documentation/route-optimization/prioritize-nearby-visits.md.txt)
- [Avoid making u-turn in a multi-stop vehicle route.](https://developers.google.com/maps/tt/route-optimization/experimental/u-turn-avoidance/make-request.md.txt) Experimental **Note:** Experimental feature; subject to pre-GA terms and limitations.
- [Optimize for pre-defined objectives.](https://developers.google.com/maps/tt/route-optimization/experimental/objectives/make-request.md.txt) Experimental **Note:** Experimental feature; subject to pre-GA terms and limitations.
- [Deliver heavier shipments first.](https://developers.google.com/maps/tt/route-optimization/experimental/load-cost/make-request.md.txt#example_scenario) Experimental **Note:** Experimental feature; subject to pre-GA terms and limitations.