Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
stylenone

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>

Panel
panelIconId2139
panelIcon:information_source:
panelIconTextℹ️
bgColor#E6FCFF

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>

Insert excerpt
APIs & Integrations
APIs & Integrations
nameinternal-api-warning
nopaneltrue

Code Block
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:

...

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>

Insert excerpt
APIs & Integrations
APIs & Integrations
nameinternal-api-warning
nopaneltrue

Code Block
curl --location 'https://gateway.<baseUrl>/scope-management/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <yourToken>' \
--data '{"query":"mutation CreateGroup($input: GroupCreateInput!) {\n  createGroup(input: $input) {\n    id\n    name\n    parentId\n  }\n}","variables":{"input":{"name":"<groupName>","parent":{"connect":{"id":"<parentId>"}}}}}'

If you want to make the flat hierarchy (multiple “root groups”) then you can leave out the part with the parent. Doing it like this:

...

Now this group is visible in the UI and users with the user management permission are able to assign and remove users from this new group.

Updating Groups

In case you did a typo or a name of a group changed you can update an existing group with the following cURL. Just replace the following placeholders: <baseUrl> / <yourToken> / <groupId> (ID of the group you want to change) / <groupName> (new name you want to set)

Insert excerpt
APIs & Integrations
APIs & Integrations
nameinternal-api-warning
nopaneltrue

Code Block
curl --location 'https://gateway.<baseUrl>/scope-management/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <yourToken>' \
--data '{"query":"mutation UpdateGroup($updateGroupId: String!, $input: GroupUpdateInput!) {\n  updateGroup(id: $updateGroupId, input: $input) {\n    id\n  }\n}","variables":{"updateGroupId":"<groupId>","input":{"name":"<groupName>"}}}'

This should give you the following result:

Code Block
{
    "data": {
        "updateGroup": {
            "id": "<groupId>",
            "name": "<groupName>"
        }
    }
}

Updating Metadata

The same cURL command can be used to add/update metadata to a group. The metadata can be passed within the parameter named configurationin the input object.

Below you can see an example where the metadata with key location with a value switzerland is added to the group specified with <groupId>.

Code Block
curl --location 'https://gateway.<baseUrl>/scope-management/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <yourToken>' \
--data '{"query":"mutation UpdateGroup($updateGroupId: String!, $input: GroupUpdateInput!) {\n  updateGroup(id: $updateGroupId, input: $input) {\n    id\n  }\n}","variables":{"updateGroupId":"<groupId>","input":{"configuration": {"location": "switzerland"}}}}'

Deleting Groups

A group can be delted as follows, make sure the groups do not have members anymore.

Code Block
curl --request POST \
    --header 'content-type: application/json' \
    --header 'Authorization: Bearer <your Token>' \
    --url https://gateway.<baseUrl>/scope-management/graphql \
    --data '{"query":"mutation DeleteGroup($deleteGroupId: String!) {\n  deleteGroup(id: $deleteGroupId) {\n    id\n  }\n}","variables":{"deleteGroupId":"group_...."}}'

Conclusion

Now you should be able to fetch, create and update groups via the API.

...