Directory API: חברי קבוצה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
הוספת חברים לקבוצה
כדי להוסיף חבר לקבוצה, משתמשים בבקשת POST
הבאה וכוללים את ההרשאה שמתוארת בקטע בקשות הרשאה. חבר קבוצה יכול להיות משתמש או קבוצה אחרת. השדה groupKey
הוא כתובת האימייל של הקבוצה של החבר החדש או השדה id
הייחודי של הקבוצה. למאפייני הבקשה והתגובה, ראו חומר העזר בנושא API:
POST https://admin.googleapis.com/admin/directory/v1/groups/groupKey/members
אם מוסיפים קבוצה כחברה בקבוצה אחרת, יכול להיות עיכוב של עד 10 דקות עד שהחברים בתת-הקבוצה יופיעו כחברים בקבוצת ההורה. בנוסף, ה-API מחזיר שגיאה לגבי מחזורים בחברות בקבוצות. לדוגמה, אם קבוצה1 היא חברה בקבוצה2, קבוצה2 לא יכולה להיות חברה בקבוצה1.
בקשת 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 מופעל באמצעות מסוף Admin. משתמש עם תפקיד 'מנהל' יכול לעשות את כל הפעולות שמשתמש עם תפקיד 'בעלים' יכול לעשות, חוץ מלמנות חבר קבוצה לבעלים או למחוק את הקבוצה. לקבוצה יכולים להיות כמה חברים עם הרשאת 'בעלים' ו'מנהל'.
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.
כשמחקים חברים:
- חברים שתסירו לא יקבלו יותר אימיילים שנשלחים לקבוצה.
- הסרת חבר מקבוצה לא מוחקת את החשבון של המשתמש.
- אם מוחקים את הבעלים של הקבוצה, הקבוצה ממשיכה לפעול כרגיל. אדמינים יכולים לנהל את הקבוצה או להקצות בעלות לחבר אחר בקבוצה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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"]]