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:
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Required | Bearer token for API authentication Example: |
Example:
{
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}/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.
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"
}
]/api/v1/users
Create User
Creates a new user account. Requires ADMIN role.
Request Body
Provide the new user credentials and role.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
username | string | Required | The unique username for the new account Example: |
password | string | Required | The initial password for the user Example: |
role | enum (ADMIN, USER) | Optional | The role of the user. Defaults to USER. Example: |
Example:
{
"username": "newuser",
"password": "secure-password",
"role": "USER"
}Response Structure
Returns the created user object.
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"
}/api/v1/users/password
Change Password
Updates the password for the currently authenticated user.
Request Body
Provide existing and new password.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
password | string | Required | The current password Example: |
newPassword | string | Required | The new password Example: |
Example:
{
"password": "old-password",
"newPassword": "new-secure-password"
}Response Structure
Standard response status codes.
No Content. Password updated successfully.
/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:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Required | The unique ID of the user Example: |
Request Body
Provide the new role.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
role | enum (ADMIN, USER) | Required | The new role to assign Example: |
Example:
{
"role": "ADMIN"
}Response Structure
Returns the updated user object.
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"
}/api/v1/users/:id
Delete User
Deletes a user account. Requires ADMIN role. You cannot delete your own account.
Path Parameters
Required Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Required | The unique ID of the user to delete Example: |
Response Structure
Standard response status codes.
No Content. User account deleted successfully.