Users API

Manage user accounts and permissions

Complete reference for managing users and their roles within Redirect Manager.

Overview

The Users API allows you to manage user accounts, including creating new users, updating roles, and changing passwords. Most endpoints require ADMIN role and a valid JWT session token.

Authentication

All API requests require authentication using a Bearer token in the Authorization header. Note: This API specifically requires a JWT session token (obtained via /auth/login), not an API token.

Request Headers:

HeaderTypeRequiredDescription
AuthorizationstringRequired

Bearer token for API authentication

Example: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Example:

{
  "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
GET

/api/v1/users

List Users

Returns a list of all users in the system. Requires ADMIN role.

Response Structure

Returns an array of user objects.

200 OK

Success. List of users returned.

Example Response:

[
  {
    "id": "uuid-1",
    "username": "admin",
    "role": "ADMIN",
    "createdAt": "2023-01-01T00:00:00.000Z",
    "updatedAt": "2023-01-01T00:00:00.000Z"
  }
]
POST

/api/v1/users

Create User

Creates a new user account. Requires ADMIN role.

Request Body

Provide the new user credentials and role.

Parameters:

ParameterTypeRequiredDescription
usernamestringRequired

The unique username for the new account

Example: newuser

passwordstringRequired

The initial password for the user

Example: secure-password

roleenum (ADMIN, USER)Optional

The role of the user. Defaults to USER.

Example: USER

Example:

{
  "username": "newuser",
  "password": "secure-password",
  "role": "USER"
}

Response Structure

Returns the created user object.

201 Created

Created. User account created successfully.

Example Response:

{
  "id": "uuid-2",
  "username": "newuser",
  "role": "USER",
  "createdAt": "2023-01-01T00:00:00.000Z",
  "updatedAt": "2023-01-01T00:00:00.000Z"
}
PATCH

/api/v1/users/password

Change Password

Updates the password for the currently authenticated user.

Request Body

Provide existing and new password.

Parameters:

ParameterTypeRequiredDescription
passwordstringRequired

The current password

Example: old-password

newPasswordstringRequired

The new password

Example: new-secure-password

Example:

{
  "password": "old-password",
  "newPassword": "new-secure-password"
}

Response Structure

Standard response status codes.

204 Response

No Content. Password updated successfully.

PATCH

/api/v1/users/:id/role

Update User Role

Updates the role for a specific user. Requires ADMIN role. You cannot change your own role.

Path Parameters

Required Parameters:

ParameterTypeRequiredDescription
idstringRequired

The unique ID of the user

Example: uuid-1

Request Body

Provide the new role.

Parameters:

ParameterTypeRequiredDescription
roleenum (ADMIN, USER)Required

The new role to assign

Example: ADMIN

Example:

{
  "role": "ADMIN"
}

Response Structure

Returns the updated user object.

200 OK

Success. User role updated.

Example Response:

{
  "id": "uuid-1",
  "username": "admin",
  "role": "ADMIN",
  "createdAt": "2023-01-01T00:00:00.000Z",
  "updatedAt": "2023-01-01T00:00:00.001Z"
}
DELETE

/api/v1/users/:id

Delete User

Deletes a user account. Requires ADMIN role. You cannot delete your own account.

Path Parameters

Required Parameters:

ParameterTypeRequiredDescription
idstringRequired

The unique ID of the user to delete

Example: uuid-2

Response Structure

Standard response status codes.

204 Response

No Content. User account deleted successfully.