Skip to main content
The Group Management API allows admins to manage Cognito user groups and group membership. Groups control access levels and permissions.

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 endpoints
  • user — 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

object
array
Array of Cognito group objectsEach group has:
  • GroupName (string): Group identifier (admin, user, or viewer)
  • Description (string): Human-readable description
  • UserPoolId (string): Cognito User Pool ID
  • CreationDate (string): ISO 8601 timestamp
  • LastModifiedDate (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

string
required
Cognito username to add to the groupExample: user@example.com
string
required
Group name to add the user toValues: admin, user, viewer

Response

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 groups
  • user — Can create and manage their own assessments
  • viewer — Can view assessments but cannot create or modify
Permissions take effect on the next token refresh (when the user logs in again or refreshes their token).

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

string
required
Cognito username to remove from the groupExample: user@example.com
string
required
Group name to remove the user fromValues: admin, user, viewer

Response

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
Permission changes take effect on the next token refresh.

Error Responses

error
Invalid group name (must be admin, user, or viewer)
error
Missing or invalid Bearer token
error
Forbidden — admin role required
error
User not found

Group Strategy

Multiple Groups

Users can belong to multiple groups simultaneously:
The user will have the union of all group permissions.

Group Hierarchy

There is no implicit hierarchy:
  • admin does not automatically inherit user permissions
  • You must explicitly add users to all relevant groups
Recommendation: Add admin users to both 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:
The API’s AdminGuard checks for the admin group in the cognito:groups claim.

Source Code

Implementation: packages/api/src/admin/groups.controller.ts