Skip to main content

Security

Manage roles and permissions for role-based access control (RBAC).

All endpoints require Authorization: Bearer <token>.


Permissions

List All Permissions

GET /permissions

Returns all available permissions.

Example

curl -X GET https://api.vanillatots.com/permissions \
-H "Authorization: Bearer $TOKEN"

Response 200 OK

[
{
"id": "uuid",
"section": "students",
"access": "read"
}
]

Create Permission

POST /permissions

Define a new permission.

Request Body

FieldTypeRequiredDescription
sectionstringYesFeature section (e.g., "students", "employees")
accessstringYesAccess level (e.g., "read", "write", "delete")

Response 200 OK — Returns the created PermissionResponse.


Roles

List All Roles

GET /roles

Returns all defined roles with their attached permissions.

Example

curl -X GET https://api.vanillatots.com/roles \
-H "Authorization: Bearer $TOKEN"

Response 200 OK

[
{
"id": "uuid",
"name": "Admin",
"avatarNumber": 1,
"permissions": [
{ "id": "uuid", "section": "students", "access": "read" }
]
}
]

Create Role

POST /roles

Create a new role.

Request Body

FieldTypeRequiredDescription
namestringYesRole name (e.g., "Teacher", "Admin")
avatarintegerYesAvatar icon number

Response 200 OK — Returns the created RoleResponse.

Get Role

GET /roles/{id}

Retrieve a single role by ID.

Path Parameters

ParameterTypeDescription
iduuidRole ID

Response 200 OK — Returns a RoleResponse with attached permissions.

Attach Permissions to Role

PATCH /roles/{id}/permissions

Update the permissions attached to a role.

Path Parameters

ParameterTypeDescription
iduuidRole ID

Request Body

FieldTypeRequiredDescription
permissionIdsstring[]YesArray of permission IDs to attach

Example

curl -X PATCH https://api.vanillatots.com/roles/{id}/permissions \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"permissionIds": ["perm-uuid-1", "perm-uuid-2"]
}'

Response 200 OK — Returns the updated RoleResponse with permissions.