Access Management API
Introduction
ROQ Platform provides access management API to easily get and apply the access and permission data for the user application. Please refer to the access management for feature guides, tutorials, and more information.
Queries
Before you can use these APIs, please install the ROQ's Node.js SDK
role()
ROQ provides the role()
(opens in a new tab) API to get the role for the specific role id. For example, to get the role with the role id 8f8a676b-7dea-4a06-a249-55e7f899aeeb
const roleData = await roqClient.asSuperAdmin().role({
id: "8f8a676b-7dea-4a06-a249-55e7f899aeeb", withUserCount: true
})
The output for the code example above is a simple JavaScript object:
{
role: {
id: '8f8a676b-7dea-4a06-a249-55e7f899aeeb',
reference: null,
description: '',
isSystemManaged: false,
key: 'channel-owner',
name: 'Channel Owner',
users: { totalCount: 1 }
}
}
Parameter | Type | Description |
---|---|---|
id | string | The role id |
withUserCount | boolean | Whether to include the user count or not |
roles()
The roles()
(opens in a new tab) API will return all the available roles on the ROQ Platform. You can filter roles based on the key and limit the result.
const rolesData = await roqClient.asSuperAdmin().roles({
limit: 10,
withUserCount: true,
filter: {
key: {
like: "mar%"
}
}
})
Parameter | Type | Description |
---|---|---|
limit | integer | Limit the results |
withUserCount | boolean | Include the user count for this role |
filter | object | Filter the result |
Mutations
Before you can use these APIs, please install the ROQ's Node.js SDK
assignRolesToUser()
The assignRolesToUser()
(opens in a new tab) API will assign a role or roles to a user.
const assignStatus = await roqClient.asSuperAdmin().assignRolesToUser({
userId: "7877d2d0-dea7-473e-a158-57eca3123906",
roleKeys: [" channel-owner", "marketing"]
})
Parameter | Type | Description |
---|---|---|
userId | string | The user id which roles to be applied |
roleKeys | array | Key roles |
unassignRolesFromUser()
The unassignRolesFromUser()
(opens in a new tab) will unassign a role or roles from the user.
const unassignStatus = await roqClient.asSuperAdmin().unassignRolesFromUser({
userId: "7877d2d0-dea7-473e-a158-57eca3123906",
roleKeys: ["marketing"]
})
Parameter | Type | Description |
---|---|---|
userId | string | The user id which a role or roles to be removed |
roleKeys | array | Key roles |
queryPlans()
The queryPlans()
(opens in a new tab) API method will get the query plans from the ROQ Platform.
const queryPlans = await roqClient.asSuperAdmin().queryPlans()