Overview
The User Management API provides endpoints for creating, reading, updating, and deleting user accounts. All endpoints require JWT authentication and return user data without sensitive password information.All endpoints in this section require a valid JWT token passed in the
Authorization header as Bearer {token}.Get All Users
Retrieve a list of all users in the system.Response
Array of UserDTO objects
Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 200 | Successfully retrieved list of users |
| 403 | Forbidden - Access denied (invalid or missing JWT token) |
Get User by ID
Retrieve a specific user by their DNI (national identification number).DNI of the user to retrieve (e.g., “11223344C”)
Response
User object containing all user information
Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 200 | Successfully retrieved user |
| 404 | User not found |
| 403 | Forbidden - Access denied |
Create User
Create a new user account with the provided details.Request Body
User’s national identification number (unique identifier)
Full name of the user
User’s phone number (must be 9 digits)
User’s password (will be encrypted before storage)
User’s email address
Whether the user should have administrator privileges (default: false)
List of role strings to assign to the user (e.g., [“ROLE_USER”])
Response
Returns the created user as a UserDTO object (password is not included in response).Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 201 | User created successfully |
| 400 | Invalid input (e.g., duplicate DNI, invalid email) |
| 403 | Forbidden - Access denied |
Update User
Update an existing user’s information.DNI of the user to update (e.g., “11223344C”)
Request Body
User’s DNI (should match the path parameter)
Updated full name
Updated phone number
Updated password
Updated email address
Updated administrator status
Updated list of roles
Response
Returns the updated user as a UserDTO object.Example Response
Example Response
Status Codes
| Code | Description |
|---|---|
| 200 | User updated successfully |
| 404 | User not found |
| 400 | Invalid input |
| 403 | Forbidden - Access denied |
Delete User
Delete a user account by DNI.DNI of the user to delete (e.g., “11223344C”)
Response
No content is returned on successful deletion.Status Codes
| Code | Description |
|---|---|
| 204 | User deleted successfully |
| 404 | User not found |
| 403 | Forbidden - Access denied |
Authentication
All User Management endpoints require JWT authentication. Include your token in the Authorization header:Error Responses
All endpoints may return the following error responses:Error type (e.g., “Forbidden”, “Not Found”, “Bad Request”)
Detailed error message
Example Error Response
Example Error Response
