This page describes how to update routes you have already created using the Roads Selection API:
- Update a route: Update details of a single route using the
patchendpoint. - Batch update routes: Update details of multiple routes in a single
request using the
batchUpdateendpoint.
Update a route
To update a route, send a PATCH request to the patch endpoint:
https://roads.googleapis.com/selection/v1/projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID?updateMask=UPDATE_MASK
The request body must be a JSON object containing the fields of the
SelectedRoute to be updated. Updatable fields include displayName,
routeAttributes, dynamicRoute, and dynamicRouting (whether the
route is fixed or dynamic). When updating route waypoints
(dynamicRoute), you must supply the entire dynamicRoute object (origin,
destination, and intermediate waypoints). Partial subfield updates are not
supported. Read-only system fields such as name, createTime, and state
can't be modified. Historical data in BigQuery retains data for the earlier and
updated waypoints under the same selectedRouteId. If you need separate
historical data, create a new route rather than performing an update.
Updating a route's waypoints (dynamicRoute) triggers a revalidation of the
route. The static_route_geometry and road_segment_ids fields in the
routes_status BigQuery table are updated accordingly.
Waypoint updates are allowed when the route is in STATE_RUNNING or
STATE_INVALID, and are rejected if the route is in STATE_VALIDATING or
STATE_DELETING. For more information, see Validation and route states.
Updating metadata such as displayName, routeAttributes, or
dynamicRouting is allowed in all states except STATE_DELETING.
The following code sample shows the structure of a PATCH request to the
patch endpoint:
curl -X PATCH -d '{
"dynamicRoute": {
"origin": {
"latitude": 38.5817,
"longitude": -121.4944
},
"destination": {
"latitude": 38.5449,
"longitude": -121.7405
}
}
}' \
-H 'X-Goog-User-Project: PROJECT_NUMBER' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
"https://roads.googleapis.com/selection/v1/projects/"\
"PROJECT_NUMBER/selectedRoutes/"\
"SELECTED_ROUTE_ID?updateMask=dynamicRoute"On success, the API returns the updated SelectedRoute resource:
{ "name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID", "dynamicRoute": { "origin": { "latitude": 38.5817, "longitude": -121.4944 }, "destination": { "latitude": 38.5449, "longitude": -121.7405 } }, "createTime": "2026-08-14T20:58:41.345418Z", "state": "STATE_VALIDATING", "dynamicRouting": TRUE_OR_FALSE }
Batch update routes
To update multiple routes in a single request, use the batchUpdate
endpoint. This endpoint lets you update up to 1,000 routes in one call. Batch
updates are atomic: if any route in the request fails validation or can't be
updated, no routes in the batch are modified.
Send a POST request to the batchUpdate endpoint:
https://roads.googleapis.com/selection/v1/projects/PROJECT_NUMBER/selectedRoutes:batchUpdate
The request body must be a JSON object containing a requests array.
Each object within this array is an UpdateSelectedRouteRequest that
specifies the route name, an optional item-level updateMask, and the
selectedRoute fields to update.
An updateMask is an optional parameter that specifies the list of fields to
be updated (displayName, routeAttributes, dynamicRouting, or the
entire dynamicRoute object). Setting updateMask=* indicates a full
replacement. An updateMask
can be specified inside each individual item in requests, or moved to the
top level of the batch request body to apply to all updated routes in the batch.
If updateMask is omitted, all updatable fields populated in the request are
implied to be updated. If an updateMask is set at both the batch level and an
item level, they must match. Specifying conflicting masks results in an
INVALID_ARGUMENT error.
The following code sample shows the structure of a POST request to the
batchUpdate endpoint:
curl -X POST -d '{
"requests": [
{
"selectedRoute": {
"name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID_1",
"displayName": "DISPLAY_NAME_1",
"dynamicRoute": {
"origin": {"latitude": 37.5, "longitude": -122.1},
"destination": {"latitude": 37.8, "longitude": -122.5}
}
},
"updateMask": "displayName,dynamicRoute"
},
{
"selectedRoute": {
"name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID_2",
"displayName": "DISPLAY_NAME_2",
"dynamicRoute": {
"origin": {"latitude": 37.5, "longitude": -122.1},
"destination": {"latitude": 37.8, "longitude": -122.5}
}
},
"updateMask": "displayName,dynamicRoute"
}
]}' \
-H 'X-Goog-User-Project: PROJECT_NUMBER' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
"https://roads.googleapis.com/selection/v1/projects/"\
"PROJECT_NUMBER/selectedRoutes:batchUpdate"On success, the API returns a response containing an array of the
SelectedRoute resources that were updated:
{ "selectedRoutes": [ { "name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID_1", "displayName": "DISPLAY_NAME_1", "dynamicRoute": { "origin": { "latitude": 37.5, "longitude": -122.1 }, "destination": { "latitude": 37.8, "longitude": -122.5 } }, "createTime": "2026-08-14T20:58:41.345418Z", "state": "STATE_VALIDATING", "dynamicRouting": TRUE_OR_FALSE }, { "name": "projects/PROJECT_NUMBER/selectedRoutes/SELECTED_ROUTE_ID_2", "displayName": "DISPLAY_NAME_2", "dynamicRoute": { "origin": { "latitude": 37.5, "longitude": -122.1 }, "destination": { "latitude": 37.8, "longitude": -122.5 } }, "createTime": "2026-08-14T20:58:41.345418Z", "state": "STATE_VALIDATING", "dynamicRouting": TRUE_OR_FALSE } ] }