Roles

Each user registered on the platform is assigned a role. It is assigned to him depending on:

  • from the rights that are assigned to the user;
  • from the actions that the user can perform on the platform;
  • from the group in which the user is included.

The role can be linked to the activities of the user when dealing with other companies. For example, roles such as analyst, developer, manager can be created and assigned. Roles may be assigned based on the expansion of rights. It can be, for example, the operator, administrator, owner. It all depends on the task.

The following standard operations can be performed when working with roles through the API platform:

  1. Getting a list of roles.
  2. Getting information about one role.
  3. Creating a new role.
  4. Role editing.
  5. Deleting a role.

Getting a list of roles

To get the full list of roles available to the user, you need to send a request GET /api/v1/roles. The response will receive an array of objects, each of which represents a configuration of a separate role.

Request

GET /api/v1/roles HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}

Response

HTTP/1.1 200 OK

BODY

Getting information about one role

In order to get the configuration of a specific role, just add the _id prefix, indicating its identification number. The response will provide the required role configuration and result of the request.

Request

GET /api/v1/roles/:id HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}

Response

HTTP/1.1 200 OK

BODY

Creating a new role

To create a new role in the request body, all fields and their values are specified, which are mandatory for any role. In particular, the rights that a user with this role should have been set.

Request

POST /api/v1/roles HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}

BODY

Response

HTTP/1.1 200 OK

BODY

Role editing

When changing field values in the role configuration, the PATCH /api/v1/roles/:id request is applied and sent.

Request

PATCH /api/v1/roles/:id HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}

BODY

Response

HTTP/1.1 200 OK

BODY

Deleting a role

In order to delete a role, you must send a DELETE /api/v1/roles/:id request.

Request

DELETE /api/v1/roles/:id HTTP/1.1
Content-Type: application/json
Authorization: Bearer {token}

Response

HTTP/1.1 200 OK

BODY

We use cookies to improve your experience. Let’s accept it and move on.