google-apigoogle-ads-api

Retrieve customer object Google Ads API


I'm using the Google Ads REST API to retrieve a list of customers and display them to the user. I want to display these customers alongside metadata like the account name, whether it's a manager account or not, etc.

I've already got a list of accessible customers using https://googleads.googleapis.com/v15/customers:listAccessibleCustomers. However, I can't find the appropriate documentation for retrieving the customer object itself using the customer id.

I've tried using the https://googleads.googleapis.com/v15/customers/{customerID}/operations/get endpoint, however this always returns a 404 resource not found error.

Any help would be appreciated. Thank you.


Solution

  • After many hours of searching, I've found you can retrieve attributes of a Google Ads customer using the following POST endpoint.

    https://googleads.googleapis.com/v15/customers/${accountID}/googleAds:search

    In the request body, specify the attributes you'd like to query using Google Ads query language in the query field.

    For example:

    // Define the request body
    const requestBody = {
        query: 'SELECT customer.id, customer.resource_name, customer.descriptive_name, customer.manager, customer.test_account FROM customer'
    };
    
    // Make the request
    axios.post(`https://googleads.googleapis.com/v15/customers/${CUSTOMER_ID}/googleAds:search`, requestBody, {
        headers: {
            "developer-token": {{DEVELOPER_TOKEN}}, // Replace with your developer token
            Authorization: `Bearer {{ACCESS_TOKEN}}`, // Replace with your access token
            'Content-Type': 'application/json',
        },
    
    })
    

    You can find a full list of customer attributes here