REST endpoint for customer_client as an alternative to listAccessibleCustomers

113 views
Skip to first unread message

Ky Nguyen

unread,
Nov 6, 2019, 5:22:01 PM11/6/19
to AdWords API and Google Ads API Forum
I'm currently working within App Script (no client libraries) that requires me to use the new Google Ads API to fetch all accounts within a customer's hierarchy upon authenticating via OAuth2. My current implementation uses the listAccessibleCustomers endpoint https://googleads.googleapis.com/v1/customers:listAccessibleCustomers but this of course only returns accounts that are directly accessible by the authenticating user. I've looked through the API reference and it seems like the only possible alternative is to use the customer_client API to retrieve every account linked to the authenticating user, but all of the example code relies on client libraries and what I'd need is a URL that I can make a request to with App Script. Any help on this would be greatly appreciated!

Thanks,
Ky

Google Ads API Forum Advisor Prod

unread,
Nov 7, 2019, 12:27:27 PM11/7/19
to adwor...@googlegroups.com

Hello,

Thank you for writing to us regarding your concern. It is only possible to get the account hierarchy using the customer_client resource via API. Unfortunately, we do not have any service in Google Ads API that you could use to get the account hierarchy by making a call from your App Scripts. However, great news is that, the feature request for your concern is already raised within our team. Please keep an eye on our blog post for future updates and announcements.

Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001UMWUzl:ref

Ky Nguyen

unread,
Nov 7, 2019, 5:15:15 PM11/7/19
to AdWords API and Google Ads API Forum
Seems I've accidentally replied privately. As a follow-up, is there a tracking buganizer for this feature request? Or can we (Google Ad Grants) open a bug for this? We'd love to stay up to date on any progress made for this feature. Thanks!

Google Ads API Forum Advisor Prod

unread,
Nov 8, 2019, 11:05:36 AM11/8/19
to adwor...@googlegroups.com

Hello,

We already have a feature request raised for your concern internally. Please keep an eye on our blog post for future updates and announcements.



Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001UMWUzl:ref

Google Ads API Forum Advisor Prod

unread,
Nov 11, 2019, 10:48:01 AM11/11/19
to adwor...@googlegroups.com
Hi Ky, this feature request was actually recently completed and is available for use. In order to accomplish your goal, make a POST request against the search endpoint (/v2/customers/{customer_id}/googleAds:search). You should structure your query to make a request against the customer_client resource. For example, your query might look something like this:

SELECT customer_client.client_customer, customer_client.resource_name, customer_client.id FROM customer_client

The result will be a flattened list of all of the accounts in the account hierarchy.

All the best,
Devin
The Google Ads API Team

 

ref:_00D1U1174p._5001UMWUzl:ref

Ky Nguyen

unread,
Nov 11, 2019, 4:29:33 PM11/11/19
to AdWords API and Google Ads API Forum
Thanks for the help so far, Devin! 

As a follow up, is there also an endpoint that I could make a request to that returns a Customer ID that I could then pass to the customer_client call? Or is the best solution to make a request to List Accessible Customers, and from the returned list of accounts, pass all of those accounts to customer clients to get the entire account hierarchy for those individual accounts?

Thank you,
Ky

Google Ads API Forum Advisor Prod

unread,
Nov 15, 2019, 4:00:24 PM11/15/19
to adwor...@googlegroups.com

Hi Ky, you must start with some customer Id in order to perform the search request. I would imagine that this would be the Id of your root manager account. The customer_client resource will then give you all of the accounts that are lower in the account hierarchy, even if there are multiple levels in that hierarchy. The response is flattened, as I mentioned, so you won't be able to see the hierarchy, just all of the accounts in the hierarchy. However, you can request the customer_client.level or customer_client.manager to piece this together client-side.

 

Best,

Reply all
Reply to author
Forward
0 new messages