Rufen Sie zum Erstellen einer Google Groups-Gruppe groups.create() mit einer Instanz der neuen Gruppe auf. Die Gruppeninstanz muss einen groupKey, einen Parent und ein label enthalten, das auf cloudidentity.googleapis.com/groups.discussion_forum festgelegt ist.
Außerdem müssen Sie den Parameter initialGroupConfig festlegen, mit dem der ursprüngliche Inhaber der Gruppe definiert wird. Sie können die folgenden Werte für diesen Parameter verwenden:
WITH_INITIAL_OWNER: Die Person, die die Anfrage sendet, wird zum Eigentümer der Gruppe. Dieser Wert sollte in den meisten Fällen verwendet werden.
EMPTY: Damit wird eine Gruppe ohne Eigentümer erstellt. Sie können diesen Wert nur verwenden, wenn Sie Google Workspace-Super Admin oder Gruppenadministrator sind. Weitere Informationen zu Google Workspace-Rollen finden Sie im Hilfeartikel Vordefinierte Administratorrollen.
Python
Im folgenden Beispiel wird eine Hilfsfunktion zum Erstellen einer Google Groups mithilfe der Python-Clientbibliothek gezeigt:
defcreate_google_group(service,customer_id,group_id,group_display_name,group_description):group_key={"id":group_id}group={"parent":"customers/"+customer_id,"description":group_description,"displayName":group_display_name,"groupKey":group_key,# Set the label to specify creation of a Google Group."labels":{"cloudidentity.googleapis.com/groups.discussion_forum":""}}try:request=service.groups().create(body=group)request.uri+="&initialGroupConfig=WITH_INITIAL_OWNER"response=request.execute()print(response)exceptExceptionase:print(e)
Nach einer Google Groups-Gruppe suchen
REST
Für die Suche nach einer Google Groups-Gruppe rufen Sie groups.search() mit einem Abfragestring auf. Wenn Sie nach allen Gruppen suchen möchten, müssen Sie nur das Label cloudidentity.googleapis.com/groups.discussion_forum angeben.
Python
Im folgenden Beispiel wird eine Hilfsfunktion zum Suchen nach einer Google Group mithilfe der Python-Clientbibliothek gezeigt:
fromurllib.parseimporturlencodedefsearch_google_groups(service,customer_id):search_query=urlencode({"query":"parent=='customerId/{}' && 'cloudidentity.googleapis.com/groups.discussion_forum' in labels".format(customer_id)})search_group_request=service.groups().search()param="&"+search_querysearch_group_request.uri+=paramresponse=search_group_request.execute()returnresponse
Nächste Schritte
Sobald eine Gruppe vorhanden ist, können Sie Mitgliedschaften für die Gruppe erstellen. Informationen zum Erstellen von Mitgliedschaften für eine Google-Gruppe finden Sie unter Mitgliedschaften für Google Groups verwalten.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[[["\u003cp\u003eThis page details the process of creating and searching for Google Groups using the Cloud Identity Groups API, highlighting the use of REST and Python client library methods.\u003c/p\u003e\n"],["\u003cp\u003eTo create a Google Group, you must use the \u003ccode\u003egroups.create()\u003c/code\u003e method, providing a \u003ccode\u003egroupKey\u003c/code\u003e, \u003ccode\u003eParent\u003c/code\u003e, and the label \u003ccode\u003ecloudidentity.googleapis.com/groups.discussion_forum\u003c/code\u003e, as well as defining an initial owner via the \u003ccode\u003einitialGroupConfig\u003c/code\u003e parameter.\u003c/p\u003e\n"],["\u003cp\u003eSearching for Google Groups involves calling the \u003ccode\u003egroups.search()\u003c/code\u003e method with a query string that includes the \u003ccode\u003ecloudidentity.googleapis.com/groups.discussion_forum\u003c/code\u003e label, and optionally a parent customer ID to filter results.\u003c/p\u003e\n"],["\u003cp\u003eBefore utilizing the Cloud Identity APIs, including the Groups API, it's crucial to complete the necessary setup steps as outlined in the "Setting up Cloud Identity" guide and the "Set up the Groups API" guide.\u003c/p\u003e\n"],["\u003cp\u003eThe customer ID format for these methods requires prepending a 'C' to the ID that is found in the Google Admin console.\u003c/p\u003e\n"]]],[],null,["# Creating and searching for Google Groups\n========================================\n\nThis page explains how to perform some fundamental operations with the\nCloud Identity Groups API.\n\nBefore you begin\n----------------\n\n| **Note:** Before you use any of the Cloud Identity APIs, you must set up Cloud Identity. See [Setting up Cloud Identity](/identity/docs/set-up-cloud-identity-admin) for instructions.\n\nPerform the following tasks before proceeding with the information on this page:\n\n- Read the [Groups API overview](/identity/docs/groups).\n\n- [Set up the Groups API](/identity/docs/how-to/setup).\n\n| **Note:** When a method requires the `customer_id`, you must prepend a \"C\" to the ID that you can view in the Google Admin console (for example, 'C046psxkn').\n\nCreating a Google Group\n-----------------------\n\n### REST\n\nTo create a Google Group, call\n[`groups.create()`](/identity/docs/reference/rest/v1/groups/create) with\nan instance of the new group. The group instance must include a `groupKey`,\n`Parent`, and `label` set to `cloudidentity.googleapis.com/groups.discussion_forum`.\n\nYou also need to set the `initialGroupConfig` parameter, which defines the\ninitial owner of the group. You can use the following values for this\nparameter:\n\n- `WITH_INITIAL_OWNER`: Makes the person sending the request the owner of the group. You should use this value in most cases.\n- `EMPTY`: Creates a group with no initial owners. You can only use this value if you're a Google Workspace Super Admin or Groups Admin. For more information about Google Workspace roles, see [Pre-built administrator\n roles](https://support.google.com/a/answer/2405986).\n\n### Python\n\nThe following example shows a helper function to create a Google Group using\nthe Python client library: \n\n def create_google_group(service, customer_id, group_id, group_display_name, group_description):\n group_key = {\"id\": group_id}\n group = {\n \"parent\": \"customers/\" + customer_id,\n \"description\": group_description,\n \"displayName\": group_display_name,\n \"groupKey\": group_key,\n # Set the label to specify creation of a Google Group.\n \"labels\": {\n \"cloudidentity.googleapis.com/groups.discussion_forum\": \"\"\n }\n }\n\n try:\n request = service.groups().create(body=group)\n request.uri += \"&initialGroupConfig=WITH_INITIAL_OWNER\"\n response = request.execute()\n print(response)\n except Exception as e:\n print(e)\n\nSearching for a Google Group\n----------------------------\n\n### REST\n\nTo search for a Google Group, call\n[`groups.search()`](/identity/docs/reference/rest/v1/groups/search) with\na query string. To search for all groups, you only need to provide the label\n`cloudidentity.googleapis.com/groups.discussion_forum`.\n\n### Python\n\nThe following example shows a helper function used to search for a Google\nGroup using the Python client library: \n\n from urllib.parse import urlencode\n\n def search_google_groups(service, customer_id):\n search_query = urlencode({\n \"query\": \"parent=='customerId/{}' && 'cloudidentity.googleapis.com/groups.discussion_forum' in labels\".format(customer_id)\n })\n search_group_request = service.groups().search()\n param = \"&\" + search_query\n search_group_request.uri += param\n response = search_group_request.execute()\n\n return response\n\nWhat's next\n-----------\n\n- After a group exists, you can create memberships for it. To create\n memberships for a Google Group, refer to\n [Managing memberships for Google Groups](/identity/docs/how-to/memberships-google-groups).\n\n- You can [update a Google Group to a security group](/identity/docs/how-to/update-group-to-security-group)."]]