> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mka1.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Groups

> Give a set of people access to several teams at once.

A **group** is a named set of users in one organization. Attach a group to a team, and every user in the group becomes a member of that team. Use a group when the same people need access to several teams, so you add them once instead of to each team's roster.

For how teams, members, and roles fit together, see [Teams and members](https://docs.mka1.com/docs/teams-and-members.md).

## How groups work

* A group belongs to one organization, and holds users who are members of that organization.
* A group's name is unique within its organization, ignoring capitals. Creating or renaming a group to a name that is already taken returns `409` with code `group_name_taken`.
* A group grants nothing on its own. Access comes from attaching it to a team.
* A group can be attached to any number of teams in its organization, and a team can have any number of groups.

### What attaching a group to a team does

When you attach a group to a team, the group's users become members of that team. They can:

* use API keys bound to the team,
* select the team in the console,
* reach everything shared with the team, such as files, vector stores, and conversations.

They join as plain members. A group never makes anyone a team admin. The team's member list shows its direct members only; the groups attached to it are listed separately.

Access through a group follows the group. Remove a user from the group, or detach the group from the team, and the user loses the access it gave them, unless they are also a direct member of the team or in another group attached to it. Adding or removing access through a group takes effect within two minutes.

Removing a user from the organization also removes them from all of its groups. Deleting a group detaches it from every team; the teams' direct members are unaffected.

### What groups do not do

* **No roles.** A group has no role, and neither does its attachment to a team. Its users are plain members of every team it is attached to.
* **No organization-level roles.** A group does not change anyone's organization role. Roles are set per person, as described in [Teams and members](https://docs.mka1.com/docs/teams-and-members.md#the-organization-and-its-owner).
* **Users only.** A group holds people, not [service accounts](https://docs.mka1.com/docs/service-accounts.md). Adding a service account returns `400` with code `group_user_not_human`. Add a service account to a team directly instead.
* **Not filled from directory sync.** You manage a group's users yourself. Directory sync does not add users to groups or remove them.

### Groups and directory sync

An organization owner or admin can add a user whose account is managed by directory sync to a group. That user then gets every team the group is attached to, even though the directory does not control that access. This is allowed on purpose: the directory manages team rosters, not group rosters.

A team managed by directory sync does not accept new group attachments. Attaching a group to it returns `403` with code `SCIM_MANAGED_TEAM`. A group that was already attached to the team stays attached, and you can still detach it.

## Before you start

* **Role.** Organization owners and admins create, rename, and delete groups, change a group's users, and attach groups to teams. Any member of the organization can list groups and read them.
* **API key.** Use a key that belongs to a person, not a service account: service account keys cannot call the group endpoints. To change groups, the key must belong to an owner or admin. To read them, any member's key works.
* **Scopes.** Reading groups and their users needs `read:groups`. Changing them needs `write:groups`. Attaching and detaching a group changes a team, so it uses the team scopes, `read:teams` and `write:teams`.

> [!WARNING]
>
> A key created before groups were available does not hold `read:groups` or `write:groups`, even an organization owner's key with every scope. It gets `403` from the group endpoints. A key cannot grant itself a scope it does not hold, so sign in to the console and add the scopes to the key under **Access → API Keys**, or [create a new key](https://docs.mka1.com/docs/authentication.md) that includes them.

The examples below use these placeholders:

| Placeholder | Value |
| :- | :- |
| `<org-id>` | Your organization's ID |
| `<team-id>` | The ID of the team to attach the group to |
| `<user-id>` | The user ID of a member of your organization |
| `<group-id>` | The `id` returned when you create the group |

## Create a group

Send a name of 1 to 120 characters. The response returns the group with its `id`.

```ts TypeScript SDK theme={null}
import { SDK } from '@meetkai/mka1';

const sdk = new SDK({ bearerAuth: 'Bearer <mka1-api-key>' });

const { group } = await sdk.auth.groups.create({
  orgId: '<org-id>',
  requestBody: { name: 'Data science' },
});
console.log(group.id);
```

```python Python SDK theme={null}
from meetkai_mka1 import SDK

sdk = SDK(bearer_auth="Bearer <mka1-api-key>")

created = sdk.auth.groups.create(
    org_id="<org-id>",
    name="Data science",
)
print(created.group.id)
```

```csharp C# SDK theme={null}
using MeetKai.MKA1;
using MeetKai.MKA1.Types.Requests;

var sdk = new SDK(bearerAuth: "Bearer <mka1-api-key>");

var created = await sdk.Auth.Groups.CreateAsync(
    orgId: "<org-id>",
    body: new CreateGroupRequestBody { Name = "Data science" }
);
Console.WriteLine(created.Object!.Group.Id);
```

```bash CLI theme={null}
mka1 auth groups create \
  --org-id <org-id> \
  --name 'Data science'
```

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/authentication/orgs/<org-id>/groups \
  --request POST \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{ "name": "Data science" }'
```

```json Response theme={null}
{
  "group": {
    "id": "<group-id>",
    "name": "Data science",
    "organizationId": "<org-id>",
    "createdAt": "2026-12-01T09:00:00.000Z",
    "updatedAt": "2026-12-01T09:00:00.000Z"
  }
}
```

## Add a user to the group

The user must already be a member of your organization. A user who is not a member returns `404`. Adding a user who is already in the group changes nothing and returns `200` with the existing membership.

```ts TypeScript SDK theme={null}
const { user } = await sdk.auth.groups.addUser({
  orgId: '<org-id>',
  groupId: group.id,
  requestBody: { userId: '<user-id>' },
});
console.log(user.email);
```

```python Python SDK theme={null}
added = sdk.auth.groups.add_user(
    org_id="<org-id>",
    group_id=created.group.id,
    user_id="<user-id>",
)
print(added.user.email)
```

```csharp C# SDK theme={null}
var added = await sdk.Auth.Groups.AddUserAsync(
    orgId: "<org-id>",
    groupId: created.Object!.Group.Id,
    body: new AddGroupUserRequestBody { UserId = "<user-id>" }
);
Console.WriteLine(
    added.TwoHundredAndOneApplicationJsonObject?.User.Email // newly added
    ?? added.TwoHundredApplicationJsonObject?.User.Email   // already in the group
);
```

```bash CLI theme={null}
mka1 auth groups add-user \
  --org-id <org-id> \
  --group-id <group-id> \
  --user-id <user-id>
```

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/authentication/orgs/<org-id>/groups/<group-id>/users \
  --request POST \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{ "userId": "<user-id>" }'
```

To take a user out of the group, send `DELETE` to `/orgs/<org-id>/groups/<group-id>/users/<user-id>`. Within two minutes they lose the teams the group gave them, except a team they also reach as a direct member or through another group.

## Attach the group to a team

Attaching needs `write:teams`, not `write:groups`. Attaching a group that is already attached changes nothing and returns `200` with the existing attachment.

```ts TypeScript SDK theme={null}
const attached = await sdk.auth.teams.attachGroup({
  orgId: '<org-id>',
  teamId: '<team-id>',
  requestBody: { groupId: group.id },
});
console.log(attached.group.attachedAt);
```

```python Python SDK theme={null}
attached = sdk.auth.teams.attach_group(
    org_id="<org-id>",
    team_id="<team-id>",
    group_id=created.group.id,
)
print(attached.group.attached_at)
```

```csharp C# SDK theme={null}
var attached = await sdk.Auth.Teams.AttachGroupAsync(
    orgId: "<org-id>",
    teamId: "<team-id>",
    body: new AttachTeamGroupRequestBody { GroupId = created.Object!.Group.Id }
);
Console.WriteLine(
    attached.TwoHundredAndOneApplicationJsonObject?.Group.AttachedAt // newly attached
    ?? attached.TwoHundredApplicationJsonObject?.Group.AttachedAt    // already attached
);
```

```bash CLI theme={null}
mka1 auth teams attach-group \
  --org-id <org-id> \
  --team-id <team-id> \
  --group-id <group-id>
```

```bash Bash theme={null}
curl https://apigw.mka1.com/api/v1/authentication/orgs/<org-id>/teams/<team-id>/groups \
  --request POST \
  --header 'Authorization: Bearer <mka1-api-key>' \
  --header 'Content-Type: application/json' \
  --data '{ "groupId": "<group-id>" }'
```

The group's users can use the team within two minutes. To see which teams a group is attached to, read the group: `GET /orgs/<org-id>/groups/<group-id>` returns them in `teams`. To list the groups attached to a team, send `GET` to `/orgs/<org-id>/teams/<team-id>/groups`. To detach a group, send `DELETE` to `/orgs/<org-id>/teams/<team-id>/groups/<group-id>`; the group and its users are unchanged.

## Manage groups in the console

Managing groups in the console is coming soon.

## See also

* [Teams and members](https://docs.mka1.com/docs/teams-and-members.md) - organizations, teams, roles, and invitations.
* [Service accounts](https://docs.mka1.com/docs/service-accounts.md) - non-human callers, which join teams directly.
* [Authentication](https://docs.mka1.com/docs/authentication.md) - API keys and scopes.
* [API reference](https://docs.mka1.com/api-reference/introduction.md) - request and response schemas for the MKA1 API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.