User Groups API
Introduction
We usually interpret a user group as precisely what the name says: a group of users. For example, you may want to group users by their home country or any other characteristic. Read more about this topic in the user group feature guide.
Mutations
createUserGroup()
To create a user group, you simply need to define a name and reference. The API detail for the method can be find here (opens in a new tab).
await client.asSuperAdmin().createUserGroup(
{ userGroup:
{ name: 'xyz789', reference: 'xyz789' }
}
);
Parameter | Type | Description |
---|---|---|
name | string | The name of the user group. For instance “My Team” |
reference | string | Reference to an object on the project-side. This could be the ID of an entity in your database |
addUsersToUserGroup()
The addUsersToUserGroup()
(opens in a new tab) API will add users to a user group, you can use this mutation with ROQ Node.js SDK or GraphQL:
await client.asSuperAdmin().addUsersToUserGroup(
{ userGroupId: "abc123",
userIds: ["abc123", '321cba']
}
);
Parameter | Type | Description |
---|---|---|
userGroupId | uuid | The ID of the user group. |
userId | array | The array of the user ids that will be added to the group |
updateUserGroup()
The updateUserGroup()
(opens in a new tab) API will update the user group data based on the user group id.
const updateGroup = await roqClient.asSuperAdmin().updateUserGroup({
id: "42103455-1e00-41bf-9714-c70a8c17caf9",
userGroup: {
name: "Video Creator",
reference: "video-creator-group"
}
})
Parameter | Type | Description |
---|---|---|
id | uuid | The ID of the user group group to be updated |
userGroup:name | string | The new user group name will replacing the old one |
userGroup:reference | string | The new user group name reference replacing the old one |
Queries
userGroups()
With the userGroups()
(opens in a new tab) API you can get all the registered user groups.
To see user groups with users you run a query like this:
await client.asSuperAdmin().userGroups({
filter: {
name: {
like: "moderator"
}
}
withUsers: true
});
Another way to fetch users by a user group could look like:
await client.asSuperAdmin().users({ filter: {
userGroupId: {equalTo: "123" }
}
});
Parameter | Type | Description |
---|---|---|
limit | integer | Limit the user groups result group. |
filter | array | Filter the user groups based on the id, name, etc. Please look into the UserGroupFilterArgType (opens in a new tab) |
userGroup()
The userGroup()
(opens in a new tab) API is used to get the information about the specific user group.
const groupId = "42103455-1e00-41bf-9714-c70a8c17caf9";
const mygroup = await roqClient.asSuperAdmin().userGroup(groupId);
Parameter | Type | Description |
---|---|---|
id | uuid | The ID of the user group. |