# Method: groups.list

Retrieves all groups of a domain or of a user given a userKey (paginated).

### HTTP request

`GET https://admin.googleapis.com/admin/directory/v1/groups`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Query parameters

| Parameters ||
|---|---|
| `customer` | `string` The unique ID for the customer's Google Workspace account. In case of a multi-domain account, to fetch all groups for a customer, use this field instead of `domain`. You can also use the `my_customer` alias to represent your account's `customerId`. The `customerId` is also returned as part of the [Users](https://developers.google.com/workspace/admin/directory/v1/reference/users) resource. You must provide either the `customer` or the `domain` parameter. |
| `domain` | `string` The domain name. Use this field to get groups from only one domain. To return all domains for a customer account, use the `customer` query parameter instead. |
| `maxResults` | `integer` Maximum number of results to return. Max allowed value is 200. |
| `orderBy` | ``enum (`https://developers.google.com/workspace/admin/directory/reference/rest/v1/groups/list#OrderBy`)`` Column to use for sorting results |
| `pageToken` | `string` Token to specify next page in the list |
| `query` | `string` Query string search. Contains one or more search clauses, each with a field, operator, and value. For complete documentation, go to [Search for groups](https://developers.google.com/workspace/admin/directory/v1/guides/search-groups). |
| `sortOrder` | ``enum (`https://developers.google.com/workspace/admin/directory/reference/rest/v1/groups/list#SortOrder`)`` Whether to return results in ascending or descending order. Only of use when orderBy is also used |
| `userKey` | `string` Email or immutable ID of the user if only those groups are to be listed, the given user is a member of. If it's an ID, it should match with the ID of the user object. Cannot be used with the `customer` parameter. |

### Request body

The request body must be empty.

### Response body

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "kind": string, "etag": string, "groups": [ { object (`https://developers.google.com/workspace/admin/directory/reference/rest/v1/groups#Group`) } ], "nextPageToken": string } ``` |

| Fields ||
|---|---|
| `kind` | `string` Kind of resource this is. |
| `etag` | `string` ETag of the resource. |
| `groups[]` | ``object (`https://developers.google.com/workspace/admin/directory/reference/rest/v1/groups#Group`)`` A list of group objects. |
| `nextPageToken` | `string` Token used to access next page of this result. |

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://apps-apis.google.com/a/feeds/groups/`
- `
  https://www.googleapis.com/auth/admin.directory.group`
- `
  https://www.googleapis.com/auth/admin.directory.group.readonly`

For more information, see the [Authorization guide](https://developers.google.com/workspace/guides/configure-oauth-consent).

## OrderBy

| Enums ||
|---|---|
| `EMAIL` | Email of the group. |

## SortOrder

| Enums ||
|---|---|
| `ASCENDING` | Ascending order. |
| `DESCENDING` | Descending order. |