> [!NOTE]
> **Note:** This document assumes you have completed the [Navigation Connect API
> setup](https://developers.google.com/maps/documentation/navigation/connect/setup-overview-requirements).

To launch a turn-by-turn navigation session securely for a driver, your backend
must create a trip and obtain an authenticated trip token from the
Navigation Connect API.

In Navigation Connect, a trip represents a navigation session to a single
destination. To create a trip and obtain the authenticated trip token
(`authToken`) required to authorize the session, send a `CreateTripRequest`
message to the `CreateTrip` method. Pass trip token to your mobile app to
include in the launch URL for Google Maps or Waze.

This guide describes how to complete this process by generating a unique trip ID
and submitting your API request.

## Construct a `CreateTripRequest` message

To create a trip and obtain a trip token, perform the following steps to
construct and send a `CreateTripRequest` message:

1. **Authenticate** : Use [Application Default Credentials (ADC)](https://docs.cloud.google.com/docs/authentication/application-default-credentials) to obtain an access token to authorize your request. For more details, see [Create an OAuth token](https://developers.google.com/maps/documentation/navigation/connect/setup-api.md.txt#create-an-oauth-token).
2. **Generate a trip ID** : Create a unique trip ID (`tripId`) in [UUIDv4](https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-4) format to identify the trip on your server.
3. **Construct the payload**: Create a JSON payload that includes your app IDs and configuration settings.
4. **Call the `CreateTrip` method**: Send a POST request to the API with the access token in the header and the payload in the body.

The following example shows how to create a trip by sending a
`CreateTripRequest` message:

```bash
#!/bin/bash

# Authenticate with ADC
access_token="$(gcloud auth application-default login --impersonate-service-account=SERVICE_ACCOUNT_EMAIL)"

# Generate a unique Trip ID
trip_id="$(uuidgen)"

# Construct the payload
payload=$(cat <<EOF
{
  "androidAppId": "ANDROID_APP_ID",
  "iosAppId": "IOS_APP_ID",
  "config": {
    "enablePubsub": true
  }
}
EOF
)

# Call the CreateTrip method to request a trip token
curl -X POST "https://navigationconnect.googleapis.com/v1/projects/PROJECT_ID/trips?tripId=${trip_id}" \
-H "Authorization: Bearer ${access_token}" \
-H "Content-Type: application/json" \
-d "${payload}"
```

### Optional configurations

You can customize the trip data by adjusting the following settings in the
`CreateTripRequest` message:

| Feature | Type | Description |
|---|---|---|
| Remaining route reporting | `boolean` | To receive the active route polyline and real-time traffic conditions, set [`config.enableRemainingRouteReporting`](https://developers.google.com/maps/documentation/navigation/connect/reference/rest/v1/projects.trips.md.txt#TripConfig.FIELDS.enable_remaining_route_reporting) to `true`. Drivers need Waze version 5.20.0.2 or later on Android, 5.20.0.1 or later on iOS, or Google Maps for Android version 26.27 or later. |
| Route deviation reporting (Waze only) | `boolean` | To track when a driver goes off-route, set [`config.enableRouteDeviationReporting`](https://developers.google.com/maps/documentation/navigation/connect/reference/rest/v1/projects.trips.md.txt#TripConfig.FIELDS.enable_route_deviation_reporting) to `true`. Drivers need Waze version 5.22 or later. |
| Trip update frequency | `boolean` | By default, Navigation Connect updates trip data every 60 seconds. To enable high-frequency updates (every 5 seconds), set [`config.enableHighFrequencyUpdates`](https://developers.google.com/maps/documentation/navigation/connect/reference/rest/v1/projects.trips.md.txt#TripConfig.FIELDS.enable_high_frequency_updates) to `true`. |
| Google Cloud Pub/Sub event generation | `boolean` | To enable trip event generation using Google Cloud Pub/Sub, set [`config.enablePubsub`](https://developers.google.com/maps/documentation/navigation/connect/reference/rest/v1/projects.trips.md.txt#TripConfig.FIELDS.enable_pubsub) to `true`. This feature is disabled by default. > [!NOTE] > **Note:** Google Cloud charges for Pub/Sub usage separately. For more information, see [Pub/Sub pricing](https://cloud.google.com/pubsub/pricing). |
| Google Cloud Pub/Sub field mask | `FieldMask` | To manage payload sizes and reduce backend processing load or Google Cloud Pub/Sub usage costs, use [`config.pubsubFieldMask`](https://developers.google.com/maps/documentation/navigation/connect/reference/rest/v1/projects.trips.md.txt#TripConfig.FIELDS.pubsub_field_mask) to exclude heavy fields (such as `execution.remainingRoute`) from your event stream. For more information about the payload size for remaining route data, see [Handle remaining route data](https://developers.google.com/maps/documentation/navigation/connect/handle-trip-data.md.txt#remaining-route). |

> [!NOTE]
> **Note:** Remaining route reporting, route deviation reporting, and high-frequency updates trigger the [Navigation Connect Enterprise SKU](https://developers.google.com/maps/documentation/navigation/connect/usage-and-billing.md.txt#pricing-for-product).

## Obtain the trip token from the response

The `CreateTrip` method returns a response containing the authenticated trip
token. To authorize the navigation session, extract this token from the response
and pass it to your mobile app to include in the launch URL.

The following code sample shows an example response:

```json
{
    "name": "projects/PROJECT_NUMBER/trips/TRIP_ID",
  "authToken": {
    "token": "BASE64_ENCODED_TRIP_TOKEN",
    "expireTime": "2026-03-06T11:09:47.476942Z"
  },
  "state": "NEW",
  "execution": {
    "traveledDistanceMeters": 0,
    "stopAddedInRoute": false
  },
  "createTime": "2026-03-05T23:09:50.768959Z",
  "updateTime": "2026-03-05T23:09:50.768959Z"
}
```

This response includes the following values:

- <var translate="no">PROJECT_NUMBER</var>: A unique numerical identifier for your project. This is distinct from your alphanumeric Project ID but represents the same Google Cloud project.
- <var translate="no">TRIP_ID</var>: The trip ID generated by your backend in UUIDv4 format.
- <var translate="no">BASE64_ENCODED_TRIP_TOKEN</var>: The authenticated trip token (`authToken.token`) returned by the `CreateTrip` method. Pass this token to your mobile app to initiate tracked turn-by-turn navigation in Google Maps or Waze.

> [!NOTE]
> **Note:** The trip token expires after 12 hours. The API response includes the exact expiration time. If the token expires before the driver starts navigating the trip, you must request a new token.

## What's next

Use the trip token to launch Google Maps or Waze.

[Launch Google Maps or Waze](https://developers.google.com/maps/documentation/navigation/connect/launch-navigation-app.md.txt)