Skip to main content

Create Role

Create a new role in the system.

Endpoint

POST /api/Roles

Authorization

Requires Administrator role.

Request Body

name
string
required
Name of the role. Must be unique.

Response

status
integer
HTTP status code: 201 Created
data
string
The ID of the newly created role
location
string
Location header with URL to the created role: /api/roles/{id}

Example Request

curl -X POST https://api.sapfiai.com/api/Roles \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "ProjectManager"
  }'

Example Response

"550e8400-e29b-41d4-a716-446655440000"

Update Role

Update an existing role’s properties.

Endpoint

PUT /api/Roles/{roleId}

Authorization

Requires Administrator role.

Path Parameters

roleId
string
required
ID of the role to update

Request Body

roleId
string
required
ID of the role (must match path parameter)
name
string
required
New name for the role

Response

status
integer
HTTP status code: 204 No Content on success

Example Request

curl -X PUT https://api.sapfiai.com/api/Roles/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "roleId": "550e8400-e29b-41d4-a716-446655440000",
    "name": "SeniorProjectManager"
  }'

Delete Role

Delete a role from the system.

Endpoint

DELETE /api/Roles/{roleId}

Authorization

Requires Administrator role.

Path Parameters

roleId
string
required
ID of the role to delete

Response

status
integer
HTTP status code: 204 No Content on success

Example Request

curl -X DELETE https://api.sapfiai.com/api/Roles/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_TOKEN"

Get All Roles

Retrieve a list of all roles in the system.

Endpoint

GET /api/Roles

Authorization

Requires Administrator role.

Response

roles
array
Array of role objects

Example Request

curl -X GET https://api.sapfiai.com/api/Roles \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Administrator",
    "normalizedName": "ADMINISTRATOR",
    "permissionCount": 15
  },
  {
    "id": "660e8400-e29b-41d4-a716-446655440001",
    "name": "User",
    "normalizedName": "USER",
    "permissionCount": 5
  },
  {
    "id": "770e8400-e29b-41d4-a716-446655440002",
    "name": "Manager",
    "normalizedName": "MANAGER",
    "permissionCount": 10
  }
]

Get Role by ID

Retrieve details of a specific role.

Endpoint

GET /api/Roles/{roleId}

Authorization

Requires Administrator role.

Path Parameters

roleId
string
required
ID of the role to retrieve

Response

id
string
Role ID
name
string
Role name
normalizedName
string
Normalized role name
permissionCount
integer
Number of permissions assigned to this role

Example Request

curl -X GET https://api.sapfiai.com/api/Roles/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Administrator",
  "normalizedName": "ADMINISTRATOR",
  "permissionCount": 15
}

Error Responses

400
error
Bad Request - Invalid request parameters or RoleId mismatch
{
  "error": "RoleId mismatch"
}
404
error
Not Found - Role does not exist
403
error
Forbidden - User does not have Administrator role

Build docs developers (and LLMs) love