Create RBAC Role
POST https://infrahub-api.nexgencloud.com/v1/auth/roles
Creates a Role-Based Access Control (RBAC) role that can be assigned to users, granting them permissions and policies associated with the role, and enabling them to execute specific resource actions.
Request body parameters
Please ensure that the request includes at least one valid ID for either the policies
or permissions
fields.
name string
Required
Name of the RBAC role being created.
description string
Required
A meaningful description of the permissions and/or policies granted by the RBAC role.
policies integer
Required
The ID(s) of the policies to be added to the RBAC role.
permissions integer
Required
The ID(s) of the permissions to be added to the RBAC role.
Attributes
status boolean
Indicates the status of the request to create a new RBAC role. true
indicates success, while false
indicates an error.
message string
A message describing the request to create an RBAC role.
role object
Returns the role
object containing the details of the permissions and policies associated with the new RBAC role. To learn more about the attributes of the role
object, click here.
curl -X POST "https://infrahub-api.nexgencloud.com/v1/auth/roles" \
-H "accept: application/json" \
-H "api_key: YOUR API KEY" \
-H "content-type: application/json" \
-d '{
"name": "string",
"description": "string",
"policies": [
1
],
"permissions": [
2
]
}'
{
"status": true,
"message": "Creating RBAC role success",
"role": {
"policies": [
{
"description": "Grants all permissions to all resources",
"id": 1,
"name": "policy:AllPermissions"
}
],
"name": "example-rbac-role",
"permissions": [
{
"resource": "Environment",
"permission": "environment:create",
"id": 2
}
],
"description": "RBAC role for documentation.",
"created_at": "2024-02-08T10:57:03",
"id": 65
}
}
Returns
The response will provide the status of the request, where true
indicates success, along with the role
object containing the configuration of the new RBAC role. Within the role
object, you'll find information about the permissions and policies assigned to the role, role ID, timestamp of creation, and the name and description you gave the role.