Directory API: Manage Customers

You can use the Directory API to manage your customers programatically. The methods in this API let you update the contact information on your G Suite domain, as well as change the primary domain for your instance.

Retrieve a Customer

To retrieve an existing customer, use the following GET HTTP request and include the authorization token described in authorizing requests. The customerKey can be the unique customerId, or my_customer to indicate the current customer.

GET https://www.googleapis.com/admin/directory/v1/customers/customerKey

A successful response returns an HTTP 200 status code. Along with the status code, the JSON response includes the customer's information:

{
  "etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
  "kind": "admin#directory#customer",
  "alternateEmail": "marty.mcfly@gmail.com",
  "id": "C03xgje4y",
  "customerDomain": "amatchmadeinspace.com",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "countryCode": "US"
  },
  "customerCreationTime": "2015-10-21T20:42:35.224Z"
}

Update an existing customer

To update an existing customer, use the following PUT HTTP request and include the authorization token described in authorizing requests. The customerKey can be the customer's unique customerId, or my_customer to indicate the current customer.

PUT https://www.googleapis.com/admin/directory/v1/customers/customerKey

A successful response returns an HTTP 200 status code. Along with the status code, the JSON response includes the newly updated customer information:

{
  "alternateEmail": "marty.mcfly@gmail.com",
  "customerDomain": "amatchmadeinspace.com",
  "language": "EN",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  }
}

A successful response returns an HTTP 200 status code. Along with the status code, the JSON response includes the customer's information:

{
  "etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
  "kind": "admin#directory#customer",
  "alternateEmail": "marty.mcfly@gmail.com",
  "id": "C03xgje4y",
  "customerDomain": "amatchmadeinspace.com",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  },
  "customerCreationTime": "2015-10-21T20:42:35.224Z"
}

Changing a customer's primary domain name

To change a customer's primary domain, use the following PUT HTTP request and include the authorization token described in authorizing requests. The customerKey must be the unique customerId, or my_customer.

PUT https://www.googleapis.com/admin/directory/v1/customers/customerKey

The JSON request body must include the new customerDomain value:

{
  "alternateEmail": "marty.mcfly@gmail.com",
  "customerDomain": "fluxcapacitor.com",
  "language": "EN",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  }
}

A successful response returns an HTTP 200 status code. Along with the status code, the JSON response includes the customer's information:

{
  "etag": "\"spqlTgq5LGeoin0BH1d0f4rpI98/LnbnRK_ZWu_omowg36CZgTKECrY\"",
  "kind": "admin#directory#customer",
  "alternateEmail": "marty.mcfly@gmail.com",
  "id": "C03xgje4y",
  "customerDomain": "fluxcapacitor.com",
  "postalAddress": {
    "organizationName": "A Match Made in Space, LLC",
    "phoneNumber": "+15558675309"
  },
  "customerCreationTime": "2015-10-21T20:42:35.224Z"
}