The Routes API is currently in Preview (pre-GA). Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. Pre-GA Offerings are covered by the Google Maps Platform Service Specific Terms. For more information, see the launch stage descriptions.

Handle request errors

The Routes API returns error messages as part of the response to a method call. For example, if you omit the API key from the request, the method returns:

{
  "error": {
    "code": 403,
    "message": "The request is missing a valid API key.",
    "status": "PERMISSION_DENIED"
  }
}

If you omit a required body parameter, such as origin, the method returns:

{
  "error": {
    "code": 400,
    "message": "Origin and destination must be set.",
    "status": "INVALID_ARGUMENT"
  }
}

For more information on errors and error handling, see Errors.