Skip to main content

Roles

Roles are the primary authorization structure for Users within the platform.

The roles Object

Field NameTypeDescription
iduuidPrimary key of the role (UUID format).
namestringName of the role.
iconstringIcon for the role. Displayed in the TrackVision UI.
descriptionstringDescription for the role. Displayed in the TrackVision UI.
usersarray of objectsThe users in this role. One-to-many relationship to users.
policiesarray of objectsThe policies assigned to this role. Many-to-many relationship to policies.
parentobjectThe parent role for this role. Many-to-one relationship to roles (recursive).
childrenarray of objectsThe child roles under this role. One-to-many relationship to roles (recursive).

List Roles

List all roles that exist in TrackVision.

Request

GET /roles

Query Parameters

Supports all global query parameters.

Response

An array of up to limit role objects. If no items are available, data will be an empty array.

Example

GET /roles

SEARCH /roles

Retrieve a Role

List an existing role by primary key.

GET /roles/:id

Query Parameters

Supports all global query parameters.

Response

Returns the requested role object.

Example

GET /roles/b4cb3b64-8580-4ad9-a099-eade6da24302

Create a Role

Create a new role.

Request

POST /roles

Provide a role object as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

A partial role object.

Response

Returns the role object for the created role.

Example

POST /roles

{
"name": "Interns",
"icon": "verified_user",
"description": null
}

Create Multiple Roles

Create multiple new roles.

Request

POST /roles

Provide an array of role objects as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

An array of partial role objects.

Response

Returns the role objects for the created roles.

Example

POST /roles

[
{
"name": "Interns",
"icon": "verified_user",
"description": null
},
{
"name": "Customers",
"icon": "person",
"description": null
}
]

Update a Role

Update an existing role.

Request

PATCH /roles/:id

Provide a partial role object as the body of your request.

Query Parameters

Supports all global query parameters.

Request Body

A partial role object.

Response

Returns the role object for the updated role.

Example

PATCH /roles/c86c2761-65d3-43c3-897f-6f74ad6a5bd7

{
"icon": "attractions"
}

Update Multiple Roles

Update multiple existing roles.

Request

PATCH /roles

{
"keys": role_id_array,
"data": partial_role_object
}

Query Parameters

Supports all global query parameters.

Request Body

keys Required
Array of primary keys of the roles you'd like to update.

data Required
Any of the role object's properties.

Response

Returns the role objects for the updated roles.

Example

PATCH /roles

{
"keys": ["c86c2761-65d3-43c3-897f-6f74ad6a5bd7", "6fc3d5d3-a37b-4da8-a2f4-ed62ad5abe03"],
"data": {
"icon": "attractions"
}
}

Delete a Role

Delete an existing role.

Request

DELETE /roles/:id

Response

Empty body.

Example

DELETE /roles/c86c2761-65d3-43c3-897f-6f74ad6a5bd7

Delete Multiple Roles

Delete multiple existing roles.

Request

DELETE /roles

Provide an array of role IDs as the body of your request.

Request Body

An array of role primary keys

Response

Empty body.

Example

DELETE /roles

["653925a9-970e-487a-bfc0-ab6c96affcdc", "c86c2761-65d3-43c3-897f-6f74ad6a5bd7"]