# Groups

Groups collect users and service accounts. Groups are granted permissions via roles.

## Assigning Users to Groups

Users can be assigned to groups in two ways:

1. Manual
2. Linked from the groups provided by your SSO provider

This behaviour can be toggled in your organisation settings. To control the default, set the following in HQ `config.yaml`.

```yaml
users_group_membership_management_mode: [manual|sso]
```

Groups can be defined with the following metadata:

1. Colour
2. Description

Each group has a resource that uniquely identifies it across an HQ installation.

## Create a Group

To create a group, go to **IAM → Groups → New Group**. Then assign members, service accounts, and roles.

<figure><img src="/files/LSN7VUltzlsC1GCKKM7V" alt=""><figcaption><p>IAM Groups</p></figcaption></figure>

You can also manage groups via the CLI and YAML, for CI/CD automation.

{% code title="terminal" %}

```bash
➜  lenses groups
Manage Groups.

Usage:
  lenses groups [command]

Aliases:
  groups, grp

Available Commands:
  create      Creates a new Group.
  delete      Deletes a group.
  get         Gets a group by its name.
  list        Lists all groups
  metadata    Manages group metadata.
  update      Updates a group.
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/devx/6.1/user-guide/iam/groups.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
