Skip to main content

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

HeaderRequiredDescription
AuthorizationYesBearer token for a System API client
Content-TypeYesMust be application/json

Path Parameters

ParameterTypeRequiredDescription
roleIdintegerYesRole identifier

Query Parameters

This endpoint does not accept query parameters.

Request Body

{
"permissionIds": [1, 2, 3]
}

Request Fields

FieldTypeRequiredDescription
permissionIdsarray of integersYesPermission IDs to add to the role

Validation Rules

  • permissionIds must not be empty
  • permissionIds must contain unique values only

Response

204 No Content

Permissions were added successfully.

This endpoint does not return a response body on success.

Errors

StatusWhen it happens
401 UnauthorizedThe bearer token is missing, invalid, or expired
403 ForbiddenThe token is valid but does not have access to this endpoint
404 Not FoundNo role exists with the provided roleId
409 ConflictOne 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.