> [!WARNING]
> **Deprecated:** The `ComputeCustomRoutes` method is [deprecated](https://developers.google.com/maps/launch-stages.md.txt#deprecated) and is closed to new customers.

When you are determining the best route for a ridesharing trip, the
fastest route may not always be the best option. You may want
to plan your route.

The Routes Preferred API lets you plan a route by specifying
a route objective using the `ComputeCustomRoutes` method.

The `ComputeCustomRoutes` method can also help with route compliance by letting
you minimize the difference between the route selected by the operator and the
route driven.

Use both the Routes Preferred API and the
[Navigation SDK](https://developers.google.com/maps/documentation/navigation-sdk)
to realize the full benefit of route planning.

> [!NOTE]
> **Note:** You do not have to use the same cloud project for the Routes Preferred API and the Navigation SDK.

> [!NOTE]
> **Note:** Unlike `ComputeRoutes` API, `ComputeCustomRoutes` only supports two travel modes, `DRIVE` (or the equivalent `TRAVEL_MODE_UNSPECIFIED`) and `TWO_WHEELER`. This method also does not support `via` intermediate waypoints. If you try to use other travel modes or `via` waypoints, the request fails. For more information about `via` waypoints, see [Routes Preferred API waypoints](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/Shared.Types/Waypoint.md.txt).

## Enable the ComputeCustomRoutes method

Before you can use the `ComputeCustomRoutes` method in your code, you must
enable it. For more information on enabling Routes Preferred API
methods, see [Getting Started](https://developers.google.com/maps/documentation/routes_preferred/get_started.md.txt).

> [!IMPORTANT]
> **Important:** Check your quota limits for Routes Preferred API methods. If you need to increase your quota limits, contact support by filing a case on the [Google Maps Platform support page](https://console.cloud.google.com/google/maps-apis/support) in the Google Cloud Console, or by calling the [Google Cloud Support Hotline](https://developers.google.com/maps/documentation/routes_preferred/support.md.txt#support_hotline).

## Use the ComputeCustomRoutes method

The `ComputeCustomRoutes` method requires that you specify a response
field mask in the input. You can provide the response field mask by using
the URL parameter `$fields` or `fields`, or by using the HTTP/gRPC header
`X-Goog-FieldMask`. For more information, see
[System Parameters](https://cloud.google.com/apis/docs/system-parameters).

The field mask value is a comma-separated list of field paths. Each field path
is a dot-separated list of field names that represent the message hierarchy.
A field name is either the JSON object key, or the protobuf field tag name.
The field path starts from the top level response message type,
and is optionally followed by one or more dots, and then the next level
of field name. In general, field paths are constructed in the following way:

```
topLevelField[.secondLevelField][.thirdLevelField][...]
```

A special case field mask is a wildcard "\*", which selects all root-level
fields.

For more information, see:

- [**gRPC API reference**](https://developers.google.com/maps/documentation/routes_preferred/reference/rpc/google.maps.routes.v1.md.txt)
- [**REST API reference**](https://developers.google.com/maps/documentation/routes_preferred/reference/rest/v1/TopLevel/computeCustomRoutes.md.txt)

For examples of using the `ComputeCustomRoutes` method, see
[Computing a Custom Route Examples](https://developers.google.com/maps/documentation/routes_preferred/custom_route_examples.md.txt).

## Calculating toll fees

For information on calculating toll fees, see
[Calculate toll fees](https://developers.google.com/maps/documentation/routes_preferred/calculate_toll_fees.md.txt).

For examples of calculating toll fees, see
[Computing a Custom Route Examples](https://developers.google.com/maps/documentation/routes_preferred/custom_route_examples.md.txt#toll-fee-examples).