Guides
API principles

Errors

The google.rpc.Status envelope, the GoogleAdsFailure with errorCode, message, trigger and location, the HTTP statuses and how to handle each one.

All of Google's JSON APIs return errors in the REST format of google.rpc.Status, inside error. In the Google Ads API, details carries a GoogleAdsFailure with one item per error. OAuth (/token, /revoke, /v1/userinfo) uses the OAuth format: {"error": "invalid_grant", "error_description": "…"}.

The envelope

json
{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [{
      "@type": "type.googleapis.com/google.ads.googleads.v26.errors.GoogleAdsFailure",
      "errors": [{
        "errorCode": { "campaignError": "DUPLICATE_CAMPAIGN_NAME" },
        "message": "Trying to modify the name of an active or paused campaign, where the name is already assigned to another active or paused campaign.",
        "trigger": { "stringValue": "Campanha X" },
        "location": { "fieldPathElements": [
          { "fieldName": "mutate_operations", "index": 1 },
          { "fieldName": "campaign_operation" },
          { "fieldName": "create" },
          { "fieldName": "name" }
        ] }
      }],
      "requestId": "Xy3…"
    }]
  }
}
  • errorCode is an object with a single key, the family, and the enum value. To check a code, look at the values: Object.values(e.errorCode)[0].
  • message is Google's official message for the code.
  • trigger is the value that caused the error: stringValue, int64Value, booleanValue or doubleValue.
  • location.fieldPathElements uses the proto names in snake_case (mutate_operations, campaign_operation, operations in per-service mutates), with index on lists.
  • The error's details appears for some codes: quotaErrorDetails, policyFindingDetails, resourceCountDetails, budgetPerDayMinimumErrorDetails.
  • The @type carries the path's version: …v25… on a call to /v25.
  • A request with several errors returns all of them, in operation order.
  • The response's request-id header equals requestId.

HTTP status

Family or caseHTTPstatus
Request, field, query and most resource errors400INVALID_ARGUMENT
headerError: INVALID_LOGIN_CUSTOMER_ID400INVALID_ARGUMENT
authenticationError, missing or invalid token401UNAUTHENTICATED
authorizationError, scope, API disabled403PERMISSION_DENIED
Nonexistent method or version404NOT_FOUND
databaseError: CONCURRENT_MODIFICATION409ABORTED
quotaError429RESOURCE_EXHAUSTED
internalError: INTERNAL_ERROR500INTERNAL
Route outside Mimicr's core501UNIMPLEMENTED
internalError: TRANSIENT_ERROR503UNAVAILABLE

Malformed JSON or JSON with an unknown field responds 400 with Google's parser message ("Invalid JSON payload received. Unknown name \"x\" at '…': Cannot find field.") and google.rpc.BadRequest. In Mimicr, fields are checked against the v26 catalog.

Errors you will see

CodeCause
authorizationError: USER_PERMISSION_DENIEDUnknown account, no access, or client account without login-customer-id
authorizationError: CUSTOMER_NOT_ENABLEDAccount canceled, closed or with incomplete setup
requestError: INVALID_CUSTOMER_IDId with hyphens or letters
fieldMaskError: FIELD_MASK_MISSINGUpdate without updateMask
mutateError: RESOURCE_NOT_FOUNDNonexistent or removed resource, or temporary id referenced before its create
newResourceCreationError: TEMP_ID_RESOURCE_HAD_ERRORSDepends on a temporary id that failed
queryError: *Invalid GAQL (see GAQL)
quotaError: RESOURCE_EXHAUSTEDDaily quota (see Quotas)
databaseError: CONCURRENT_MODIFICATIONAnother mutate on the same campaign

How to handle each one

  • 400 INVALID_ARGUMENT: fix the request; show errors[].message to whoever entered the data.
  • 401: renew the access token with the refresh token; if the refresh gives invalid_grant, ask for authorization again.
  • 403: check login-customer-id, the account status and the scopes. SERVICE_DISABLED carries metadata.activationUrl.
  • 409 CONCURRENT_MODIFICATION, 500 and 503: retry with increasing backoff (for example 2, 4 and 6 seconds).
  • 429: wait for the retryDelay in quotaErrorDetails.

Data Manager

The Data Manager uses the same envelope without GoogleAdsFailure. details carries google.rpc.ErrorInfo (domain: datamanager.googleapis.com), google.rpc.RequestInfo and, on validation errors, google.rpc.BadRequest with fieldViolations[{field, description, reason}]. See Conversions via Data Manager.