13
votes

Many of the Directory API calls require a customer parameter referred to as the "Immutable id of the Google Apps account. (string)".

e.g. GET https://www.googleapis.com/admin/directory/v1/customer/customer/domains

I have no idea how to find/generate this for my Google Apps account. I am an admin.

Can someone point me in the right direction please?

5
You can call the method Users.get with your own account, at the end of the response you can find the customerId.Gerardo

5 Answers

15
votes

I was able to find the customerId as follows

  1. Go to admin.google.com
  2. Security -> Set up single sign-on (SSO)

You will see URLs like this:

https://accounts.google.com/o/saml2/idp?idpid=Cxxxxxxxx

That Cxxxxxxxx is your customerId

3
votes

If you are part of an organization, you can find it here as Organization ID: https://play.google.com/work/adminsettings?pli=1

It works for G Suite accounts and Gmail accounts that are associated with an organization, but not for individual Gmail accounts.

2
votes

The easiest way I found was to use the APIs Explorer at the bottom of the documentation for the Customers: get method on the Directory API (Admin SDK). Enter 'my_customer' for the customerKey on the form and hit the 'Authorize and Execute' button.

The response will include the CustomerId (e.g. Cxxxxxxxx) as the "id". The entire response will look something like this:

{
  "kind": "admin#directory#customer",
  "id": string,
  "etag": etag,
  "customerDomain": string,
  "alternateEmail": string,
  "postalAddress": {
    "organizationName": string,
    "countryCode": string,
  },
  "language": string,
  "customerCreationTime": datetime
}
6
votes

Had the same question, so I had to contact their chat support.

The official answer was:
There are no any web interface to look up this information - as I would expect for example in "organisation admin panel". The only way to get this information is from the code.

You have to write extra code to request information about any existing user:
(Link to API Docs - GET: https://www.googleapis.com/admin/directory/v1/users)
And in the response, you can find field customerId which is the same for each user in the company across all domains.

That is the only way to find your organisation customerId...

Not user-friendly, so I will submit "Feature Request" right now to Google.

0
votes

I found something simpler: gcloud organizations list. It will give you DISPLAY_NAME, ID and DIRECTORY_CUSTOMER_ID (this is what your are looking for) for all you organizations.