Authentication
All endpoints require JWT Bearer token (Cognito) with admin role.Available Groups
The system supports three groups:admin— Full admin access to all API endpointsuser— Standard user access (can create and manage own assessments)viewer— Read-only access
List Groups
GET /api/admin/groups
Returns all Cognito user groups defined in the user pool.
Response
Array of Cognito group objectsEach group has:
GroupName(string): Group identifier (admin,user, orviewer)Description(string): Human-readable descriptionUserPoolId(string): Cognito User Pool IDCreationDate(string): ISO 8601 timestampLastModifiedDate(string): ISO 8601 timestamp
Example Request
Example Response
Add User to Group
POST /api/admin/users/:username/groups/:groupName
Adds a Cognito user to a group. Assigning the admin group grants full admin access to the API.
Path Parameters
Cognito username to add to the groupExample:
[email protected]Group name to add the user toValues:
admin, user, viewerResponse
Example Request
Permissions Impact
Adding a user to a group immediately grants them the associated permissions:admin— Can access all/api/admin/*endpoints, manage prompts, users, and groupsuser— Can create and manage their own assessmentsviewer— Can view assessments but cannot create or modify
Remove User from Group
DELETE /api/admin/users/:username/groups/:groupName
Removes a Cognito user from a group. Removing from the admin group revokes admin access immediately on the next token refresh.
Path Parameters
Cognito username to remove from the groupExample:
[email protected]Group name to remove the user fromValues:
admin, user, viewerResponse
Example Request
Permissions Impact
Removing a user from a group revokes the associated permissions:- If removed from
admin, the user loses access to all admin endpoints - If removed from
user, the user cannot create new assessments - If removed from
viewer, the user loses read access
Error Responses
Invalid group name (must be
admin, user, or viewer)Missing or invalid Bearer token
Forbidden — admin role required
User not found
Group Strategy
Multiple Groups
Users can belong to multiple groups simultaneously:Group Hierarchy
There is no implicit hierarchy:admindoes not automatically inherituserpermissions- You must explicitly add users to all relevant groups
admin and user groups:
Default Group
New users are not automatically added to any group. Admins must explicitly assign groups:JWT Token Claims
Cognito encodes group membership in the JWT token:AdminGuard checks for the admin group in the cognito:groups claim.
Source Code
Implementation:packages/api/src/admin/groups.controller.ts