Documentation

User Management

Use self-service profiles and permission-protected administrative user lifecycle operations.

Edit on GitHub

User management

The users module supports self-service account changes and administrative user management. All user routes require a bearer access token. Administrative routes also require a specific effective permission.

The default base path is http://localhost:3000/api/v1/users.

User states

StateMeaning
PENDING_VERIFICATIONRegistered but not yet email verified
ACTIVEAllowed to authenticate and use the API
SUSPENDEDRetained but blocked from normal access

Soft deletion is tracked separately with deletedAt. Administrative user responses may include deleted records when requested.

Self-service operations

Self-service routes need only a valid access token:

Method and pathPurpose
GET /users/meReturn the current profile and effective access
PATCH /users/meReplace the current display name
POST /users/me/email-changeVerify the current password and send an email-change verification

Get the current profile:

plaintext
curl http://localhost:3000/api/v1/users/me \
  --header 'Authorization: Bearer <access-token>'

Update the display name:

plaintext
curl --request PATCH http://localhost:3000/api/v1/users/me \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "displayName": "Updated Name"
  }'

Request an email change:

plaintext
curl --request POST http://localhost:3000/api/v1/users/me/email-change \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "newEmail": "updated@example.com",
    "currentPassword": "current-password-at-least-12-characters"
  }'

The email changes only after the recipient submits the verification token through POST /auth/verify-email.

Administrative permissions

The default RBAC seed creates:

PermissionAdministrative capability
users.createCreate managed users
users.readList and inspect users
users.updateUpdate profile, status, or email
users.deleteSoft-delete users
users.restoreRestore soft-deleted users

The seeded ADMIN role receives all system user permissions. The SUPER_ADMIN role bypasses individual permission checks. Effective permissions can still differ because of per-user overrides.

Administrative operations

Method and pathPermissionPurpose
POST /usersusers.createCreate an active, email-verified managed user
GET /usersusers.readList users with pagination and filters
GET /users/:idusers.readInspect a user by UUID
PATCH /users/:idusers.updateChange display name or active/suspended status
POST /users/:id/email-changeusers.updateSend a managed email-change verification
DELETE /users/:idusers.deleteSoft-delete an account
POST /users/:id/restoreusers.restoreRestore a soft-deleted account

Create a managed user

plaintext
curl --request POST http://localhost:3000/api/v1/users \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "email": "managed@example.com",
    "displayName": "Managed User",
    "password": "managed-password-at-least-12-characters"
  }'

Managed users start as ACTIVE with their initial email marked as verified.

List users

plaintext
curl \
  'http://localhost:3000/api/v1/users?page=1&limit=20&search=example&status=ACTIVE&includeDeleted=false' \
  --header 'Authorization: Bearer <access-token>'

Supported query fields:

FieldBehavior
pagePage number, default 1
limitItems per page, default 20, maximum 100
searchUser search text
roleIdFilter by assigned role UUID
statusFilter by PENDING_VERIFICATION, ACTIVE, or SUSPENDED
includeDeletedInclude soft-deleted users when true

Update status or profile

plaintext
curl --request PATCH http://localhost:3000/api/v1/users/<user-uuid> \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "displayName": "Managed Account",
    "status": "SUSPENDED"
  }'

Only ACTIVE and SUSPENDED are accepted as administrative status updates. Suspension invalidates existing access by incrementing the user's authentication version.

Soft-delete and restore

plaintext
curl --request DELETE http://localhost:3000/api/v1/users/<user-uuid> \
  --header 'Authorization: Bearer <access-token>'

curl --request POST http://localhost:3000/api/v1/users/<user-uuid>/restore \
  --header 'Authorization: Bearer <access-token>'

Deletion is soft and invalidates existing authentication. Restoration retains the account record and increments its authentication version again.

Administrative safeguards

  • Administrators cannot delete their own account.
  • Managed email changes for the acting administrator must use the self-service endpoint.
  • RBAC policy prevents callers from managing users whose protected access is outside their authority.
  • The final active super administrator cannot be removed through an access replacement.
  • Duplicate current or target email addresses return a conflict.

Use Role-Based Access Control to manage assignments and Authentication for verification and session behavior.

On this page