API Call Structure

This guide describes the elements of an API call and demonstrates making a basic call using cURL.

If you're using a client library to interact with the API, you won't need to worry about the underlying request details. However, knowing a bit about them can come in handy when testing and debugging.

Google Ads API is a gRPC API, with REST bindings. This means that there are two ways of making calls to the API.

  1. [Preferred] Create the body of the request as a protocol buffer, send it to the server using HTTP/2, deserialize the response to a protocol buffer, and interpret the results.

  2. [Optional] Create the body of request as a JSON object, send it to the server using HTTP 1.1, deserialize the response as a JSON object, and interpret the results.

Endpoint

This is the Google Ads API server endpoint where all requests are sent:

https://googleads.googleapis.com

Request URL

The request URL has two parts: an endpoint and a URL suffix. Constructing a request URL for a method consists of:

  1. Getting the HTTP method name and URL template suffix from the service proto file.
  2. Appending the URL template suffix to the server endpoint.
  3. Making necessary parameter substitutions to the suffix.

Example

To get the URL of the resource, refer to its resource_name. For example, for CampaignBudget, the resource_name description has the path

customers/{customer_id}/campaignBudgets/{budget_id}

If you wanted to call the CampaignBudgetService.MutateCampaignBudgets method with an HTTP POST, you would transform that URL to

/v1/customers/{customer_id}/campaignBudgets:mutate

The full URL endpoint for this method can be constructed by substituting {customer_id} with the Google Ads customer ID and appending it to the Google Ads API server endpoint.

So for a customer with ID 123-456-7890, the full URL endpoint would look like this:

https://googleads.googleapis.com/v1/customers/1234567890/campaignBudgets:mutate

Composite ID

If the ID of an object is not globally unique, a composite ID for that object is constructed by prepending its parent ID and an underscore character.

For example, since an ad group ad ID is not globally unique, we prepend its parent object (ad group) ID to it to make a unique composite ID:

  • AdGroupId of 123 + ~ + AdGroupAdId of 45678 = composite ad group ad ID of 123~45678.

Request header

These are the HTTP headers (or grpc metadata) that accompany the body in the request:

Authorization

You need to include an OAuth2 access token in the form of Authorization : Bearer YOUR_ACCESS_TOKEN that identifies either a manager account acting on behalf of a client or an advertiser directly managing their own account. Directions for retrieving an access token can be found in the OAuth2 guide. An access token is valid for an hour after you acquire it; when it expires, refresh the access token to retrieve a new one. Note that our client libraries automatically refresh expired tokens.

developer-token

A developer token is a 22-character string that uniquely identifies a Google Ads API developer. An example developer token string is ABcdeFGH93KL-NOPQ_STUv. The developer token should be included in the form of developer-token : ABcdeFGH93KL-NOPQ_STUv.

login-customer-id

This is the customer ID of the authorized customer to use in the request, without hyphens (-). If your access to the customer account is through a manager account, this header is required and must be set to the customer ID of the manager account.

https://googleads.googleapis.com/v1/customers/1234567890/campaignBudgets:mutate

Setting the login-customer-id is equivalent to choosing an account in the Google Ads UI after signing in or clicking on your profile image at the top right. If you do not include this header, it defaults to the operating customer.

Response headers

The following headers (or grpc trailing-metadata) are returned with the response body. We recommend that you log these values for debugging purposes.

request-id

The request-id is a string that uniquely identifies this request.

Send feedback about...

Google Ads API
Google Ads API
Need help? Visit our support page.