/
Managing groups & group members via API

Managing groups & group members via API

 

The new user management UI enables you to assign users to groups. But creating new groups is currently not available via UI. So this is a guide which leads you through the calls needed for it.

Preferences

  • Token of a user / service-user which has admin role (chat.admin.all) assigned → <yourToken>

  • The base URL of your application → <baseUrl>

Check here how to get a token: How to get a Token for our APIs

Fetching groups

With the following cURL you can fetch all available groups of the organisation the user/service-user belongs to. Just replace the following placeholders: <baseUrl> / <yourToken>

curl --location 'https://gateway.<baseUrl>/scope-management/graphql' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <yourToken>' \ --data '{"query":"query AllGroups {\n allGroups {\n id\n name\n parentId\n createdAt\n updatedAt\n }\n}","variables":{}}'

This should give you the following result:

{ "data": { "allGroups": [ { "id": "group_123456789032eqd21xocgdfw", "name": "Root Group", "parentId": null, "createdAt": "2021-05-17T10:35:30.212Z", "updatedAt": "2021-09-23T09:36:11.846Z" }, { "id": "group_0987654321jviq7tiure95uh", "name": "GPT-4 Group", "parentId": "group_123456789032eqd21xocgdfw", "createdAt": "2021-05-20T08:54:10.839Z", "updatedAt": "2021-05-20T08:54:10.839Z" }, ... ] } }

 

As you can see the groups can be hierarchical. This is something to keep in mind when creating new groups.

Creating a group

Before creating a group you need to know how you want to organise your organisation/company. As default there is a Root Group created where all users (also new ones) get assigned on signup. Groups can be hierarchical. Imagine a setup where you have the Root Group and create a new group with IT and the parent is the Root Group and another group called Development with the parent IT. People added as member to the group Development will automatically also gain access to the scopes/spaces of this group itself and all parent groups. With this setup you are able to replicate the organisation chart of your company and manage access. Its also possible to have a flat hierarchy of groups with multiple “root groups” and no parents or children.

Now lets create a group. This can be done with this cURL. Just replace the following placeholders: <baseUrl> / <yourToken> / <groupName> / <parentId>