Directory API:管理客戶

您可以使用 Directory API,以程式輔助的方式管理客戶。這個 API 中的方法可讓您更新 G Suite 網域的聯絡資訊,以及變更執行個體的主網域。

擷取客戶

如要擷取現有客戶,請使用以下 GET HTTP 要求,並加入授權要求中所述的授權權杖。customerKey 可以是專屬客戶 ID,或 my_customer 代表目前客戶。

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

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼,JSON 回應還包含客戶資訊:

{
  "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"
}

更新現有顧客

如要更新現有客戶,請使用以下 PUT HTTP 要求,並加入授權要求中所述的授權權杖。customerKey 可以是客戶的專屬客戶 ID,或 my_customer 來表示目前客戶。

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

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼,JSON 回應中還會包含更新過的客戶資訊:

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

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼,JSON 回應還包含客戶資訊:

{
  "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"
}

變更客戶的主網域名稱

如要變更客戶的主網域,請使用以下 PUT HTTP 要求並加入授權要求中所述的授權權杖。customerKey 必須是專屬客戶 ID,或 my_customer

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

JSON 要求主體必須包含新的 customerDomain 值:

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

成功的回應會傳回 HTTP 200 狀態碼。除了狀態碼,JSON 回應還包含客戶資訊:

{
  "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"
}