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>
Clients or developers can use Unique internal APIs, but must not build any automation or integration with them. These APIs do not guarantee backward compatibility and are excluded from any Service Level Agreement (SLA). Unique will not roll back changes to fix broken integrations caused by updates to internal APIs. Consequently, reliance on these APIs for critical functions is strongly discouraged.
Learn more about the use of Internal APIs.
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>
Clients or developers can use Unique internal APIs, but must not build any automation or integration with them. These APIs do not guarantee backward compatibility and are excluded from any Service Level Agreement (SLA). Unique will not roll back changes to fix broken integrations caused by updates to internal APIs. Consequently, reliance on these APIs for critical functions is strongly discouraged.
Learn more about the use of Internal APIs.
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:
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>"}}}'
This should respond with the following successful response with your replaced <groupName>, a new unique <groupId> and if you did it hierarchical the <parentId> otherwise null
:
{ "data": { "createGroup": { "id": "<groupId>", "name": "<groupName>", "parentId": "<parentId>" or null } } }
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)
Clients or developers can use Unique internal APIs, but must not build any automation or integration with them. These APIs do not guarantee backward compatibility and are excluded from any Service Level Agreement (SLA). Unique will not roll back changes to fix broken integrations caused by updates to internal APIs. Consequently, reliance on these APIs for critical functions is strongly discouraged.
Learn more about the use of Internal APIs.
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:
{ "data": { "updateGroup": { "id": "<groupId>", "name": "<groupName>" } } }
Deleting Groups
A group can be delted as follows, make sure the groups do not have members anymore.
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.
Author |
---|