Use the following APIs to create, fetch, update, and delete roles.

Create a Role

Required Permissions

You must have the Create Role permission to perform this operation.

API
/api/roles
Method
POST
Required Parameters
Name Description
name

string

Role name.
description

string

Description of the role.
permissions
  • Permission number

    integer

Permission numbers.
Input Example
{
  "name": "",
  "description": "",
  "permissions": [
   // Integer array of permission numbers
  ]
}
Response
{
  "id": "string"
}

Get a Role by ID

Required Permissions

You must have the View Role permission to perform this operation.

API
/api/roles/{id}
Method
GET
Required Parameters
Name Description
id

string

Role ID.
Response
{
  "id": "",
  "name": "",
  "description": "",
  "isDefault": false,
  "permissions": [
    {
      "permissionNumber":1,
      "name": "",
      "description": ""
    },
    {
      "permissionNumber":2,
      "name": "",
      "description": ""
    }
  ],
  "createdTime":"",
  "lastUpdatedTime":"",
  "updateVersion":1
}

Get a List of Roles

Required Permissions

You must have the View Role permission to perform this operation.

API
/api/roles
Method
GET
Parameters
None
Response
{
  "roles": [
    {
      "id": "",
      "name": "",
      "isDefault": false,
      "description":"",
      "createdTime": "",
      "lastUpdatedTime": "",
      "updateVersion":1
    }
  ],
  "pageInfo": {
    "page": 1,
    "pageSize": 10,
    "totalElements": "4",
    "totalPages": "1"
  }
}

Update a Role

Required Permissions

You must have the Edit Role permission to perform this operation.

API
/api/roles/{id}
Method
PUT
Required Parameters
Name Description
name

string

Role name.
description

string

Description of the role.
permissions
  • Permission number

    integer

  • name

    string

  • description

    string

Permission number, name, and description of the role.
updateVersion

string

Version of the update.
Input Example
{
  "name": "",
  "description":"",
  "permissions":[],
  "updateVersion":1
}
Response
{
  "id": "string"
}

Delete a Role

Required Permissions

You must have the Delete Role permission to perform this operation.

API
/api/roles/{id}
Method
DELETE
Required Parameters
Name Description
id

string

Role ID.
Response
{}

List Users for Role

Required Permissions

You must have the View Role permission to perform this operation.

API
/api/console-roles/{id}/users?page.number=1&page.size=10
Method
GET
Required Parameters
None
Response
{
    "users": [
        {
            "id": "",
            "userName": "",
            "displayName": "",
            "status": "",
            "orgId": "",
            "createdTime": "",
            "lastUpdatedTime": "",
            "updateVersion": 5,
            "createdBy": "s",
            "lastUpdatedBy": ""
        }
    ],
    "pageInfo": {
        "page": 1,
        "pageSize": 10,
        "totalElements": "1",
        "totalPages": "1"
    }
}