Create a trip and get a trip token

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) to obtain an access token to authorize your request. For more details, see Create an OAuth token.
  2. Generate a trip ID: Create a unique trip ID (tripId) in UUIDv4 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:

#!/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 (Waze only) boolean

To receive the active route polyline and real-time traffic conditions, set config.enableRemainingRouteReporting to true.

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 to true.

Google Cloud Pub/Sub event generation boolean

To enable trip event generation using Google Cloud Pub/Sub, set config.enablePubsub to true. This feature is disabled by default.

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 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.

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:

{
    "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:

  • PROJECT_NUMBER: A unique numerical identifier for your project. This is distinct from your alphanumeric Project ID but represents the same Google Cloud project.
  • TRIP_ID: The trip ID generated by your backend in UUIDv4 format.
  • BASE64_ENCODED_TRIP_TOKEN: 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.

What's next

Use the trip token to launch Google Maps or Waze.

Launch Google Maps or Waze