To create a Google Group, call
groups.create() with
an instance of the new group. The group instance must include a groupKey,
Parent, and label set to cloudidentity.googleapis.com/groups.discussion_forum.
You also need to set the initialGroupConfig parameter, which defines the
initial owner of the group. You can use the following values for this
parameter:
WITH_INITIAL_OWNER: Makes the person sending the request the owner of
the group. You should use this value in most cases.
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
roles.
Python
The following example shows a helper function to create a Google Group using
the Python client library:
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)
Searching for a Google Group
REST
To search for a Google Group, call
groups.search() with
a query string. To search for all groups, you only need to provide the label
cloudidentity.googleapis.com/groups.discussion_forum.
Python
The following example shows a helper function used to search for a Google
Group using the Python client library:
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
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 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)."]]