--- title: "Enable Admin SDK API and List Google Workspace Group Members" slug: "dex-wf-list-google-workspace-group-members" updated: 2026-11-30T16:16:08Z published: 2026-11-30T16:16:08Z canonical: "documentation.sysaid.com/dex-wf-list-google-workspace-group-members" --- > ## Documentation Index > Fetch the complete documentation index at: https://documentation.sysaid.com/llms.txt > Use this file to discover all available pages before exploring further. # Enable Admin SDK API and List Google Workspace Group Members Search for a group by name, paginate through its full membership, and export the roster to CSV using the Google Admin Directory API. **Complexity:** Intermediate. **Impact:** user-management + audit + reporting + google-workspace. ## Why use this workflow Admins are frequently asked to produce the definitive list of who belongs to a company-wide distribution or security group, for example *"all employees"*, *"all managers"*, or a department roster. The Google Admin console exposes this in the UI, but it does not export cleanly and forces you to open each group one at a time. This workflow walks through the programmatic path: enabling the **Admin SDK API** in your Google Cloud project, granting the right OAuth scopes, locating a group whose display name may not exactly match what the requester called it, and paginating the `members` endpoint to export a complete, sorted CSV. Run this workflow when you need an auditable snapshot of group membership for access reviews, HR headcount reconciliation, license reviews, or mail-merge distribution lists. ## Expected outcomes ### You have: - The **Admin SDK API** enabled in your Google Cloud project (a one-time prerequisite). - A confirmed group email when the display name is ambiguous (for example, "all employees" resolves to `all-staff@domain.com`). - A complete, paginated list of group members, including nested groups, suspended accounts, and external members. - A sorted CSV export (`email,role,status,type`) suitable for HR or audit handoff. - A reusable approach that you can point at any group email in the future. ## Risks and considerations ### Things to watch for - **Admin SDK API must be enabled.** The first call returns `HTTP 403: Admin SDK API has not been used in project <N> before or it is disabled`. After you enable it, allow some time for propagation before you retry. - **Scope consent is separate from API enablement.** Granting `admin.directory.group.readonly` and `admin.directory.group.member.readonly` is a distinct step. A 403 after you enable the API usually means missing scopes. - **Group display names are not unique.** A request for "all employees" may resolve to several groups, such as *All Staff*, *All Managers*, or *Engineering All*. Confirm with the requester before you export. - **Query syntax is limited.** The `query` parameter on `/groups` does *not* support `name:value` like the users endpoint. It accepts only `memberKey=`. Use client-side filtering on the full list instead. - **Pagination is required.** The default `maxResults` is 200. A larger group is silently truncated unless you follow `nextPageToken`. - **Privacy.** Member email lists are sensitive. Store the CSV in a restricted location and purge it after use per your data retention policy. - **Nested groups.** If a member has `type=GROUP`, the roster is not flat. You may need to expand it recursively to get the true user set. ## Required permissions | Permission | Why it's needed | | --- | --- | | Admin SDK API enabled in GCP project | Required before any Directory API call succeeds. The API is disabled by default. | | https://www.googleapis.com/auth/admin.directory.group.readonly | List and read group metadata (name, email, member count). | | https://www.googleapis.com/auth/admin.directory.group.member.readonly | List members of a specific group. | | Google Workspace Super Admin or delegated Groups Admin role | Required to invoke Directory API endpoints with the `customer=my_customer` or `domain=` parameters. | ## Ask Dex Paste the prompt into a Dex conversation. ### Prompt for IT admins ``` List all members of the {group_name} group in Google Workspace and export the roster to CSV. If the exact group name is ambiguous, show me candidate matches first so I can confirm before exporting. ``` ### How an end user can ask Dex ``` Can you send me the list of people in the {group_name} email group? ``` ## Manual steps (admin center) ### 1. Open the Groups list Go to [Google Admin console](https://admin.google.com) > **Directory** > **Groups**. ### 2. Search for the group Use the search bar at the top of the Groups page. Because display names are not unique, try partial matches like `all` or `employees` and review the results carefully. Note the group's **email address**, which is the unique key. ### 3. Open the group Select the group name to open its details page, then select the **Members** tab. ### 4. Export members 1. Select **Members** in the left sidebar of the group page. 2. Select the **Download members** button (cloud-download icon) in the top right. 3. Choose **All members** and select **Download**. A CSV is emailed to you and is also available under Tasks in the Admin console. ### 5. Verify counts Compare the row count in the downloaded CSV to the *Direct members* count shown on the group overview. If they differ, the group likely contains nested groups. Expand them separately or use the API workflow below. The Admin console export covers direct members and may not include suspended or external accounts. For audit-grade output, use the API. ## Google Admin Directory API ### Prerequisite: enable the Admin SDK API Open `https://console.developers.google.com/apis/api/admin.googleapis.com/overview?project={PROJECT_ID}` and select **Enable**. Allow time for propagation before your first call. ### 1. List groups in the domain ``` GET https://admin.googleapis.com/admin/directory/v1/groups?domain={domain}&maxResults=200 Authorization: Bearer {access_token} ``` Paginate with `nextPageToken` until all groups are retrieved. The `query` parameter on this endpoint accepts only `memberKey=`, not `name:`. Filter client-side on `name` or `email`. ### 2. Get a specific group by email (if you know it) ``` GET https://admin.googleapis.com/admin/directory/v1/groups/{group_email} ``` Returns 404 if the email is wrong. Confirm with step 1 if unsure. ### 3. List members with pagination ``` GET https://admin.googleapis.com/admin/directory/v1/groups/{group_email}/members?maxResults=200 ``` Response shape: ``` {  "kind": "admin#directory#members",  "members": [    {      "email": "user@domain.com",      "role": "MEMBER",      "type": "USER",      "status": "ACTIVE"    }  ],  "nextPageToken": "..." } ``` Follow `nextPageToken` until it is absent. Each member has a `type` of `USER`, `GROUP`, `CUSTOMER`, or `EXTERNAL`. Decide whether to expand nested groups recursively. ### Common errors | Status | Meaning | Fix | | --- | --- | --- | | 403 *insufficient authentication scopes* | OAuth token is missing directory scopes | Re-consent with `admin.directory.group.readonly` and `admin.directory.group.member.readonly` | | 403 *Admin SDK API has not been used...* | API is disabled in the GCP project | Enable it at the console URL above and allow time for propagation | | 404 *Resource Not Found: groupKey* | Group email does not exist | List groups first to confirm the email | | 400 *Invalid Input: name:value* | Unsupported query syntax on `/groups` | List all groups and filter client-side | ## Command line (gcloud and curl) Use `gcloud` (to obtain an access token) and `curl` with `jq` to list a group's members and export them to CSV, with pagination handled in your script. ### Prerequisites - `gcloud` CLI installed and authenticated as a Workspace admin with the required scopes: ``` gcloud auth application-default login --scopes=\  https://www.googleapis.com/auth/admin.directory.group.readonly,\  https://www.googleapis.com/auth/admin.directory.group.member.readonly,\  https://www.googleapis.com/auth/cloud-platform ``` - `jq` installed. - Admin SDK API enabled in the active GCP project. ### Approach 1. Acquire an access token with `gcloud auth application-default print-access-token`. 2. If you are searching by name, paginate `/groups` and print the matches (name, email, member count) so that you can pick one. 3. For the chosen group, paginate `/groups/{key}/members` by using `nextPageToken`. 4. Write a sorted CSV with the columns `email,role,status,type`. 5. Report HTTP errors with an actionable hint (403 scopes, 404 not found, API not enabled).