Directory API: สมาชิกกลุ่ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เพิ่มสมาชิกลงในกลุ่ม
หากต้องการเพิ่มสมาชิกลงในกลุ่ม ให้ใช้คำขอ POST
ต่อไปนี้และรวมการให้สิทธิ์ที่อธิบายไว้ในคำขอสิทธิ์ สมาชิกกลุ่มอาจเป็นผู้ใช้หรือกลุ่มอื่นก็ได้ โดย groupKey
คืออีเมลกลุ่มของสมาชิกใหม่หรือ id
ที่ไม่ซ้ำกันของกลุ่ม ดูพร็อพเพอร์ตี้คำขอและการตอบกลับได้ในเอกสารอ้างอิง API
POST https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members
หากคุณเพิ่มกลุ่มเป็นสมาชิกของอีกกลุ่มหนึ่ง ระบบอาจใช้เวลาถึง 10 นาทีก่อนที่สมาชิกของกลุ่มย่อยจะปรากฏเป็นสมาชิกของกลุ่มหลัก นอกจากนี้ API จะแสดงข้อผิดพลาดสำหรับรอบการเป็นสมาชิกกลุ่ม เช่น หาก group1 เป็นสมาชิกของ group2 แสดงว่า group2 จะเป็นสมาชิกของ group1 ไม่ได้
คำขอ JSON
คําขอ JSON ต่อไปนี้แสดงตัวอย่างเนื้อหาคําขอที่สร้างสมาชิกกลุ่ม อีเมลของสมาชิกคือ liz@example.com และบทบาทของสมาชิกในกลุ่มคือ MEMBER
คำขอ POST
ใช้ NNNNN สำหรับ groupKey
POST https://admin.googleapis.com/admin/directory/v1/groups/NNNNN/members
{
"email": "liz@example.com",
"role": "MEMBER"
}
role
ของสมาชิกกลุ่มอาจเป็นสิ่งต่อไปนี้
OWNER
– บทบาทนี้จะเปลี่ยนการส่งข้อความไปยังกลุ่ม เพิ่มหรือนำสมาชิกออก เปลี่ยนบทบาทของสมาชิก เปลี่ยนการตั้งค่าของกลุ่ม และลบกลุ่มได้ OWNER
ต้องเป็นสมาชิกของกลุ่ม
MANAGER
– บทบาทนี้จะใช้ได้ก็ต่อเมื่อเปิดใช้ Google Workspace โดยใช้คอนโซลผู้ดูแลระบบเท่านั้น บทบาทผู้จัดการจะทำทุกอย่างได้เช่นเดียวกับบทบาทเจ้าของ ยกเว้นการทำให้สมาชิกเป็นเจ้าของหรือลบกลุ่ม กลุ่มหนึ่งจะมีสมาชิกที่มีบทบาทเป็น "เจ้าของ" และ "ผู้จัดการ" ได้หลายคน
MEMBER
– บทบาทนี้จะสมัครรับข้อมูลกลุ่ม ดูที่เก็บการสนทนา และดูรายชื่อสมาชิกของกลุ่มได้ ดูข้อมูลเพิ่มเติมเกี่ยวกับบทบาทของสมาชิกได้ที่ศูนย์ช่วยเหลือด้านการดูแลระบบ
การตอบสนองของ JSON
การตอบกลับที่สำเร็จจะแสดงรหัสสถานะ HTTP 200 และข้อมูลการเป็นสมาชิกของสมาชิก id
คือรหัสการเป็นสมาชิกที่ไม่ซ้ำกันของสมาชิก
{
"kind": "directory#member",
"id": "group member's unique ID",
"email": "liz@example.com",
"role": "MEMBER",
"type": "GROUP"
}
type
ของสมาชิกกลุ่มอาจเป็นสิ่งต่อไปนี้
GROUP
– สมาชิกเป็นกลุ่มอื่น
MEMBER
– สมาชิกเป็นผู้ใช้
อัปเดตการเป็นสมาชิกกลุ่ม
หากต้องการอัปเดตการเป็นสมาชิกกลุ่ม ให้ใช้คำขอ PUT
ต่อไปนี้และรวมการให้สิทธิ์ที่อธิบายไว้ในคำขอสิทธิ์ โดย groupKey
คืออีเมลของกลุ่มหรือ id
ที่ไม่ซ้ำของกลุ่ม และ memberKey
คืออีเมลหลักของผู้ใช้หรือกลุ่ม อีเมลแทนของผู้ใช้ หรือ id
ที่ไม่ซ้ำของผู้ใช้ ดูพร็อพเพอร์ตี้คำขอและการตอบกลับได้ในเอกสารอ้างอิง API
PUT https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members/memberKey
คำขอ JSON
คำขอ JSON ต่อไปนี้แสดงตัวอย่างเนื้อหาคำขอที่อัปเดตการตั้งค่าการเป็นสมาชิกกลุ่ม อีเมลของสมาชิกคือ liz@example.com และบทบาทของสมาชิกในกลุ่มเปลี่ยนจาก MEMBER
เป็น MANAGER
groupKey
ของคำขอ PUT
ในตัวอย่างนี้คือ NNNNN ดูข้อมูลเกี่ยวกับบทบาทสมาชิก เจ้าของ และผู้จัดการได้ที่ศูนย์ช่วยเหลือของการดูแลระบบ
PUT https://admin.googleapis.com/admin/directory/v1/groups/NNNNN/members/liz@example.com
{
"email": "liz@example.com",
"role": "MANAGER"
}
การตอบสนองของ JSON
การตอบกลับที่สำเร็จจะแสดงรหัสสถานะ HTTP 200 และข้อมูลการเป็นสมาชิกที่อัปเดต id
คือรหัสการเป็นสมาชิกที่ไม่ซ้ำกันของสมาชิก
{
"kind": "directory#member",
"id": "group member's unique ID",
"email": "liz@example.com",
"role": "MANAGER",
"type": "GROUP"
}
เรียกข้อมูลสมาชิกของกลุ่ม
หากต้องการเรียกข้อมูลการเป็นสมาชิกกลุ่ม ให้ใช้คำขอ GET
ต่อไปนี้และรวมการให้สิทธิ์ที่อธิบายไว้ในคำขอสิทธิ์ โดย groupKey
คืออีเมลของกลุ่มหรือ id
ที่ไม่ซ้ำของกลุ่ม และ memberKey
คืออีเมลหลักของผู้ใช้หรือกลุ่ม อีเมลแทนของผู้ใช้ หรือ id
ที่ไม่ซ้ำของผู้ใช้ ดูพร็อพเพอร์ตี้คำขอและการตอบกลับได้ในเอกสารอ้างอิง API
GET https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members/memberKey
การตอบสนองของ JSON
การตอบกลับที่สำเร็จจะแสดงรหัสสถานะ HTTP 200 และข้อมูลการเป็นสมาชิกของสมาชิก id
คือรหัสการเป็นสมาชิกที่ไม่ซ้ำกันของสมาชิก
{
"kind": "directory#member",
"id": "group member's unique ID",
"email": "liz@example.com",
"role": "MANAGER",
"type": "GROUP"
}
เรียกข้อมูลสมาชิกกลุ่มทั้งหมด
หากต้องการดึงข้อมูลสมาชิกกลุ่มทั้งหมด ให้ใช้คำขอ GET
ต่อไปนี้และรวมการให้สิทธิ์ที่อธิบายไว้ในคำขอสิทธิ์ โดย groupKey
คืออีเมลของกลุ่มหรือ id
ที่ไม่ซ้ำของกลุ่ม สตริงการค้นหา roles
(ไม่บังคับ) คือตัวกรองที่ช่วยให้คุณดึงข้อมูลสมาชิกกลุ่มตามบทบาทได้ และคอลเล็กชันบทบาทที่ได้จะอยู่ในลำดับที่ระบุไว้ในตัวกรอง roles
ดูพร็อพเพอร์ตี้คำขอและการตอบกลับได้ในเอกสารอ้างอิง API ตัวอย่างนี้มีการขึ้นบรรทัดใหม่เพื่อให้ง่ายต่อการอ่านทำความเข้าใจ
GET https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members
?pageToken=pagination token
&roles=one or more of OWNER,MANAGER,MEMBER separated by a comma
&maxResults=maximum results per response page
ระบบจะแสดงสมาชิกทั้งหมดตามลําดับตัวอักษรของอีเมล และใช้สตริงการค้นหา pageToken
สำหรับคำตอบที่มีสมาชิกจำนวนมาก ในกรณีที่มีการแบ่งหน้า การตอบกลับจะแสดงพร็อพเพอร์ตี้ nextPageToken
ซึ่งมีโทเค็นสำหรับหน้าถัดไปของผลการตอบกลับ คําขอถัดไปจะใช้โทเค็นนี้เป็นค่าสตริงการค้นหา pageToken
การตอบสนองของ JSON
การตอบกลับที่สำเร็จจะแสดงรหัสสถานะ HTTP 200 และรายการข้อมูลสมาชิก id
คือรหัสการเป็นสมาชิกที่ไม่ซ้ำกันของสมาชิก มี nextPageToken
สำหรับรายการสมาชิกกลุ่มที่ติดตามผลในการตอบกลับนี้
{
"kind": "directory#members",
"members": [
{
"kind": "directory#member",
"id": "group member's unique ID",
"email": "liz@example.com",
"role": "MANAGER",
"type": "USER"
},
{
"kind": "directory#member",
"id": "group member's unique ID",
"email": "radhe@example.com",
"role": "MANAGER",
"type": "USER"
}
],
"nextPageToken": "NNNNN"
}
ลบการเป็นสมาชิกในกลุ่ม
หากต้องการลบการเป็นสมาชิกของสมาชิกในกลุ่ม ให้ใช้คำขอ DELETE
ต่อไปนี้และรวมการให้สิทธิ์ที่อธิบายไว้ในคำขอสิทธิ์ โดย groupKey
คือ id
ที่ไม่ซ้ำของกลุ่ม และ memberKey
คืออีเมลหลักของผู้ใช้หรือสมาชิกกลุ่มที่ถูกลบ หรือ id
ที่ไม่ซ้ำของผู้ใช้ ดูพร็อพเพอร์ตี้คำขอและการตอบกลับได้ในเอกสารอ้างอิง API
DELETE https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members/memberKey
ตัวอย่างเช่น คําขอ DELETE
นี้จะลบสมาชิกที่มี groupKey
เป็น nnn และ memberKey
เป็นอีเมลหลักของผู้ใช้ liz@example.com
DELETE https://admin.googleapis.com/admin/directory/v1/groups/nnnn/members/liz@example.com
การตอบกลับที่สำเร็จจะแสดงรหัสสถานะ HTTP 200
สิ่งที่จะเกิดขึ้นเมื่อลบสมาชิก
- สมาชิกที่คุณนำออกจะไม่ได้รับการส่งอีเมลถึงกลุ่มอีกต่อไป
- การนำสมาชิกออกจากกลุ่มจะไม่ลบบัญชีผู้ใช้
- หากคุณลบเจ้าของกลุ่ม กลุ่มนี้จะยังคงทำงานได้ตามปกติ ในฐานะผู้ดูแลระบบ คุณสามารถจัดการกลุ่มหรือมอบหมายให้สมาชิกกลุ่มคนอื่นเป็นเจ้าของแทนได้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-29 UTC
[null,null,["อัปเดตล่าสุด 2025-08-29 UTC"],[],[],null,["# Directory API: Group Members\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1. [Add a member to a group](#create_member) 2. [Update a group membership](#update_member) 3. [Retrieve a group's member](#get_member) 4. [Retrieve all group members](#get_all_members) 5. [Delete membership in a group](#delete_member) |\n\nAdd a member to a group\n-----------------------\n\nTo add a member to a group, use the following `POST` request and include the authorization described in [Authorize requests](/workspace/admin/directory/v1/guides/authorizing). A group member can be a user or another group. The `groupKey` is the new member's group email address or the group's unique `id`. For the request and response properties, see the [API Reference](/workspace/admin/directory/v1/reference/members/insert): \n\n```\nPOST https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members\n```\n\nIf you add a group as a member of another group, there may be a delay of up to 10 minutes before the child group's members appear as members of the parent group. In addtion, the API returns an error for cycles in group memberships. For example, if group1 is a member of group2, group2 cannot be a member of group1.\n\n### JSON request\n\nThe following JSON request shows a sample request body that creates a group member. The member's email address is liz@example.com and the member's role in the group is as a `MEMBER`. The `POST` request uses NNNNN for the `groupKey`: \n\n```\nPOST https://admin.googleapis.com/admin/directory/v1/groups/NNNNN/members\n``` \n\n```transact-sql\n{\n \"email\": \"liz@example.com\",\n \"role\": \"MEMBER\"\n}\n```\n\nA group member's `role` can be:\n\n- `OWNER` -- This role can change send messages to the group, add or remove members, change member roles, change group's settings, and delete the group. An `OWNER` must be a member of the group.\n- `MANAGER` -- This role is only available if the Google Workspace is enabled using the Admin console. A MANAGER role can do everything done by an OWNER role except make a member an OWNER or delete the group. A group can have multiple OWNER and MANAGER members.\n- `MEMBER` -- This role can subscribe to a group, view discussion archives, and view the group's membership list. For more information about member roles, see the [administration help center](http://support.google.com/a/bin/answer.py?answer=167094).\n\n\u003cbr /\u003e\n\n### JSON response\n\nA successful response returns an [HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes) and the member's membership information. The `id` is the member's unique membership ID: \n\n```carbon\n{\n \"kind\": \"directory#member\",\n \"id\": \"group member's unique ID\",\n \"email\": \"liz@example.com\",\n \"role\": \"MEMBER\",\n \"type\": \"GROUP\"\n }\n```\n\nA group member's `type` can be:\n\n- `GROUP` -- The member is another group.\n- `MEMBER` -- The member is a user\n\n\u003cbr /\u003e\n\nUpdate a group membership\n-------------------------\n\nTo update a group membership, use the following `PUT` request and include the authorization described in [Authorize requests](/workspace/admin/directory/v1/guides/authorizing). The `groupKey` is the group's email address or the group's unique `id`, and the `memberKey` is the user's or group's primary email address, a user's alias email address, or the user's unique `id`. For the request and response properties, see the [API Reference](/workspace/admin/directory/v1/reference/members/update): \n\n```\nPUT https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members/memberKey\n```\n| **Note:** The API also supports the [patch semantics](/workspace/admin/directory/v1/guides/performance#patch).\n\n### JSON request\n\nThe following JSON request shows a sample request body that updates a group membership settings. The member's email address is liz@example.com and the member's role in the group is changed from a `MEMBER` to a `MANAGER`. The `PUT` request's `groupKey` in this example is NNNNN. For information about the MEMBER, OWNER and MANAGER roles, see the [administration help center](http://support.google.com/a/bin/answer.py?answer=167094): \n\n```\nPUT https://admin.googleapis.com/admin/directory/v1/groups/NNNNN/members/liz@example.com\n``` \n\n```transact-sql\n{\n \"email\": \"liz@example.com\",\n \"role\": \"MANAGER\"\n}\n```\n\n### JSON response\n\nA successful response returns an [HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes) and the updated membership information. The `id` is the member's unique membership ID: \n\n```carbon\n{\n \"kind\": \"directory#member\",\n \"id\": \"group member's unique ID\",\n \"email\": \"liz@example.com\",\n \"role\": \"MANAGER\",\n \"type\": \"GROUP\"\n }\n```\n\nRetrieve a group's member\n-------------------------\n\nTo retrieve a group membership, use the following `GET` request and include the authorization described in [Authorize requests](/workspace/admin/directory/v1/guides/authorizing). The `groupKey` is the group's email address or the group's unique `id`, and the `memberKey` is the user's or group's primary email address, a user's alias email address, or the user's unique `id`. For the request and response properties, see the [API Reference](/workspace/admin/directory/v1/reference/members/get): \n\n```\nGET https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members/memberKey\n```\n\n### JSON response\n\nA successful response returns an [HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes) and the member's membership information. The `id` is the member's unique membership ID: \n\n```carbon\n{\n \"kind\": \"directory#member\",\n \"id\": \"group member's unique ID\",\n \"email\": \"liz@example.com\",\n \"role\": \"MANAGER\",\n \"type\": \"GROUP\"\n }\n```\n\nRetrieve all group members\n--------------------------\n\nTo retrieve all group members, use the following `GET` request and include the authorization described in [Authorize requests](/workspace/admin/directory/v1/guides/authorizing). The `groupKey` is the group's email address or the group's unique `id`. The optional `roles` query string is a filter allowing you to retrieve group members by role and the resulting role collections are in the order given in the `roles` filter. For the request and response properties, see the [API Reference](/workspace/admin/directory/v1/reference/members/list). For readability, this example uses line returns: \n\n```\nGET https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members\n?pageToken=pagination token\n&roles=one or more of OWNER,MANAGER,MEMBER separated by a comma\n&maxResults=maximum results per response page\n```\n\nAll members are returned in the alphabetical order of the members' email addresses. And use the `pageToken` query string for responses with large number of members. In the case of pagination, the response returns the `nextPageToken` property which has a token for the next page of response results. Your next request uses this token as the `pageToken` query string value.\n\n### JSON response\n\nA successful response returns an [HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes) and the list of member information. The `id` is the member's unique membership ID. There is a `nextPageToken` for the follow-on list of group members in this response: \n\n```carbon\n{\n \"kind\": \"directory#members\",\n \"members\": [\n {\n \"kind\": \"directory#member\",\n \"id\": \"group member's unique ID\",\n \"email\": \"liz@example.com\",\n \"role\": \"MANAGER\",\n \"type\": \"USER\"\n },\n {\n \"kind\": \"directory#member\",\n \"id\": \"group member's unique ID\",\n \"email\": \"radhe@example.com\",\n \"role\": \"MANAGER\",\n \"type\": \"USER\"\n }\n ],\n \"nextPageToken\": \"NNNNN\"\n}\n```\n\nDelete membership in a group\n----------------------------\n\nTo delete a member's membership in a group, use the following `DELETE` request and include the authorization described in [Authorize requests](/workspace/admin/directory/v1/guides/authorizing). The `groupKey` is the group's unique `id`, and `memberKey` is the deleted user or group member's primary email address or the user's unique `id`. For the request and response properties, see the [API Reference](/workspace/admin/directory/v1/reference/members/delete).: \n\n```\nDELETE https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members/memberKey\n```\nFor example, this `DELETE` request deletes the member whose `groupKey` is nnn and whose `memberKey` is the user's primary email address, liz@example.com: \n\n```\nDELETE https://admin.googleapis.com/admin/directory/v1/groups/nnnn/members/liz@example.com\n```\n\nA successful response returns an [HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes).\n\nWhen a member is deleted:\n\n- Members you remove no longer receive email addressed to the group.\n- Removing a member from a group does not delete the user's account.\n- If you delete the group owner, the group still works normally. As an administrator, you can manage the group or assign ownership to another group member\n\n\u003cbr /\u003e"]]