Skip to content

Roles

Roles are named permissions assigned to users directly or through group membership. They surface in access token JWT claims.

Required scopes: roles:read for GET requests, roles:write for POST / PUT / DELETE.


{
"id": 7,
"name": "admin",
"description": "Full workspace administrator",
"scope": "TENANT",
"tenantId": 1
}
FieldTypeDescription
idintegerInternal numeric ID
namestringRole name. Pattern: [a-zA-Z0-9._-]+
descriptionstring | nullOptional human-readable description
scopeTENANT | CLIENTTENANT = workspace-wide; CLIENT = application-scoped
tenantIdintegerThe workspace this role belongs to

Scope behavior in JWT claims:

  • TENANT roles appear in realm_access.roles
  • CLIENT roles appear in resource_access.<clientId>.roles

GET /t/{slug}/api/v1/roles

Example request:

Terminal window
curl https://auth.yourdomain.com/t/my-app/api/v1/roles \
-H "Authorization: Bearer kauth_my-app_KEY"

Response 200 OK:

{
"data": [
{ "id": 7, "name": "admin", "description": "Full workspace administrator", "scope": "TENANT", "tenantId": 1 },
{ "id": 8, "name": "viewer", "description": null, "scope": "TENANT", "tenantId": 1 }
],
"meta": { "total": 2, "offset": 0, "limit": 20 }
}

POST /t/{slug}/api/v1/roles

Request body:

{
"name": "moderator",
"description": "Can manage user content",
"scope": "tenant"
}
FieldRequiredDescription
nameYesPattern [a-zA-Z0-9._-]+, unique within scope in workspace
descriptionNoOptional description
scopeNotenant or client. Default: tenant

Response 201 Created: Returns the created role object.

Error responses:

StatusCondition
409 ConflictRole name already exists in this scope
422 UnprocessableInvalid name format

GET /t/{slug}/api/v1/roles/{roleId}

Response 200 OK: Returns the role object.


PUT /t/{slug}/api/v1/roles/{roleId}

Updates the role name and/or description. Changing the name does not affect existing assignments — roles are referenced by ID internally.

Request body:

{
"name": "moderator",
"description": "Updated description"
}
FieldRequiredDescription
nameYesNew role name
descriptionNoNew description (pass null to clear)

Response 200 OK: Returns the updated role object.


DELETE /t/{slug}/api/v1/roles/{roleId}

Permanently deletes the role and removes all user and group assignments. This action cannot be undone.

Response 204 No Content