Fetch all roles.
Method: POST
Endpoint: /roles
CURL:
curl -X POST http://localhost/roles
Response:
[
{
"role_id": 1,
"role_name": "Headmaster"
},
{
"role_id": 2,
"role_name": "Teacher"
},
...
]
Fetch all permissions.
Method: POST
Endpoint: /permissions
CURL:
curl -X POST http://localhost/permissions
Response:
[
{
"permission_id": 1,
"permission_name": "full_access"
},
{
"permission_id": 2,
"permission_name": "student"
},
...
]
Fetch permissions for a specific role.
Method: POST
Endpoint: /roles/{role_id}/permissions
CURL:
curl -X POST http://localhost/roles/1/permissions
Response:
[
{
"permission_name": "student",
"is_create": true,
"is_update": true,
"is_delete": false,
"is_view": true
},
...
]
Assign permissions to a specific role.
Method: POST
Endpoint: /roles/{role_id}/permissions
CURL:
curl -X POST http://localhost/roles/1/permissions \
-H "Content-Type: application/json" \
-d '{
"permission_id": 2,
"permissions": {
"is_create": true,
"is_update": true,
"is_delete": false,
"is_view": true
}
}'
Request Body:
{
"permission_id": 2,
"permissions": {
"is_create": true,
"is_update": true,
"is_delete": false,
"is_view": true
}
}
Response:
{
"message": "Permission assigned successfully"
}
Remove a permission from a specific role.
Method: DELETE
Endpoint: /roles/{role_id}/permissions/{permission_id}
CURL:
curl -X DELETE http://localhost/roles/1/permissions/2
Response:
{
"message": "Permission removed successfully"
}
Add a new role.
Method: POST
Endpoint: /roles
CURL:
curl -X POST http://localhost/roles \
-H "Content-Type: application/json" \
-d '{
"role_name": "New Role"
}'
Request Body:
{
"role_name": "New Role"
}
Response:
{
"message": "Role added successfully"
}
Add a new permission.
Method: POST
Endpoint: /permissions
CURL:
curl -X POST http://localhost/permissions \
-H "Content-Type: application/json" \
-d '{
"permission_name": "New Permission"
}'
Request Body:
{
"permission_name": "New Permission"
}
Response:
{
"message": "Permission added successfully"
}