Add Permissions To Role
Add one or more permissions to a role.
Authentication
This endpoint requires a bearer access token for the System API.
Endpoint
POST /api/v1/roles/{roleId}/permissions
Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json
Request
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token for a System API client |
Content-Type | Yes | Must be application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
roleId | integer | Yes | Role identifier |
Query Parameters
This endpoint does not accept query parameters.
Request Body
{
"permissionIds": [1, 2, 3]
}
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
permissionIds | array of integers | Yes | Permission IDs to add to the role |
Validation Rules
permissionIdsmust not be emptypermissionIdsmust contain unique values only
Response
204 No Content
Permissions were added successfully.
This endpoint does not return a response body on success.
Errors
| Status | When it happens |
|---|---|
401 Unauthorized | The bearer token is missing, invalid, or expired |
403 Forbidden | The token is valid but does not have access to this endpoint |
404 Not Found | No role exists with the provided roleId |
409 Conflict | One or more submitted permission IDs are invalid |
404 Example
Role not found.
409 Example
One or more permission IDs are invalid.
Behavior
- The endpoint is additive
- Existing permission assignments remain unchanged
- Permission IDs already assigned to the role are ignored
- Only new permission assignments are created
Example
cURL
curl -X POST "https://your-tenant.guardhouse.cloud/api/v1/roles/1/permissions" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"permissionIds": [1, 2, 3]
}'
.NET SDK
using Guardhouse.SDK.Models.Roles;
using Guardhouse.SDK.Services;
// Assumes AddGuardhouseClientWithApiClients(...) is already configured.
app.MapPost("/example/roles/{roleId:int}/permissions", async (int roleId, IGuardhouseRolesClient rolesClient) =>
{
var updated = await rolesClient.AddPermissionsToRoleAsync(roleId, new AddPermissionsToRoleRequest
{
PermissionIds = new[] { 1, 2, 3 }
});
return updated ? Results.NoContent() : Results.NotFound();
});
Python SDK
# SDK support is in development.
# Use raw HTTP for now.
#
# Example shape:
# import requests
# response = requests.post(
# "https://your-tenant.guardhouse.cloud/api/v1/roles/1/permissions",
# headers={
# "Authorization": "Bearer YOUR_ACCESS_TOKEN",
# "Content-Type": "application/json",
# },
# json={"permissionIds": [1, 2, 3]},
# )
Notes
- Use Get Role By ID after this operation to verify the updated permission matrix for the role.
- Use Get Permissions if you need to inspect available permission IDs before assignment.