Here's an example curl request body for a single origin, single-destination
route. It uses field masks to request a route token, along with the route
duration, distance, and route polyline:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eTo get a route token from the Routes API, you must set \u003ccode\u003etravelMode\u003c/code\u003e to \u003ccode\u003eDRIVE\u003c/code\u003e and \u003ccode\u003eroutingPreference\u003c/code\u003e to either \u003ccode\u003eTRAFFIC_AWARE\u003c/code\u003e or \u003ccode\u003eTRAFFIC_AWARE_OPTIMAL\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eEnsure that none of your route waypoints are via waypoints when requesting a route token.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003eroutes.routeToken\u003c/code\u003e field mask in your request to ensure that a route token is returned.\u003c/p\u003e\n"],["\u003cp\u003eThe route generated with a token may vary slightly from the planned route due to dynamic road conditions, and it's recommended to use the token soon after generation.\u003c/p\u003e\n"],["\u003cp\u003eThe route token can be used in the Navigation SDK for your planned route.\u003c/p\u003e\n"]]],["To obtain a route token from the Routes API, set `travelMode` to `DRIVE` and `routingPreference` to `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`. Ensure no waypoints are \"via\" waypoints. Include `routes.routeToken` in the `X-Goog-FieldMask`. Use the token promptly, as dynamic road conditions can cause deviations. The token can be used in the Navigation SDK. An example cURL request demonstrates how to request a token with other route data.\n"],null,["# Get a route token\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nTo request that the Compute Routes returns route\ntokens for generated routes, follow these steps:\n\n1. Set the following parameters required to return a route token:\n\n - Set `travelMode` to `DRIVE`.\n - Set `routingPreference` to `TRAFFIC_AWARE` or `TRAFFIC_AWARE_OPTIMAL`.\n2. Check that none of your route waypoints are via waypoints.\n\n3. Specify the `routes.routeToken` field mask to return a route token:\n\n X-Goog-FieldMask: routes.routeToken\n\n| **Note:** Due to dynamic road conditions, routes generated with a given token may differ from the planned route. To minimize the differences, use the token within minutes of token generation.\n\nYou can use the route token for your planned route in the Navigation SDK.\nFor more details, see:\n\n- [Plan a route (Android)](/maps/documentation/navigation/android-sdk/customize-route#use-token)\n- [Plan a route (iOS)](/maps/documentation/navigation/ios-sdk/route-customizations#use-token)\n\nRoute token example\n-------------------\n\nHere's an example curl request body for a single origin, single-destination\nroute. It uses field masks to request a route token, along with the route\nduration, distance, and route polyline: \n\n```curl\ncurl -X POST -d\n{\"origin\":{\n \"location\": {\n \"latLng\":{\n \"latitude\": -37.8167,\n \"longitude\": 144.9619\n }\n }\n},\n\"destination\":{\n \"location\": {\n \"latLng\":{\n \"latitude\":-37.8155,\n \"longitude\": 144.9663\n }\n }\n},\n\"routingPreference\":\"TRAFFIC_AWARE\",\n\"travelMode\":\"DRIVE\"\n}\n-H 'X-Goog-Api-Key: YOUR_API_KEY' \\\n-H X-Goog-FieldMask: routes.routeToken,routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline\n'https://routes.googleapis.com/directions/v2:computeRoutes'\n```\n\nFor more details, see the\n[Compute Routes API reference](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes)."]]