Endpoint
Updates an existing user’s information. Note that the username cannot be changed after registration.
Path Parameters
Unique user identifier.Example: 0f4df2de-fffb-4a24-9891-381ecf4f0f87
Request Body
User’s email address. Must be a valid email format.Validation:
- Required
- Must be a valid email address
Example: jdoe@jdoe.com
User’s first name.Validation:
- Required
- Max length: 100 characters
Example: Jane
User’s last name.Validation:
- Required
- Max length: 100 characters
Example: Doe II
User’s role in the system.Validation:
- Required
- Must be one of:
ADMIN, USER, GUEST
Example: ADMIN
Whether the user account is active.Validation:Example: true
Response
Unique identifier for the user.Example: 0f4df2de-fffb-4a24-9891-381ecf4f0f87
The user’s username (unchanged).Example: jdoe
The updated email address.Example: jdoe@jdoe.com
The updated first name.Example: Jane
The updated last name.Example: Doe II
The updated role.Example: ADMIN
ISO 8601 timestamp when the user was created (unchanged).Example: 2024-01-15T10:30:00
ISO 8601 timestamp when the user was last updated.Example: 2024-01-15T10:35:00
Whether the user account is active.Example: true
Status Codes
User updated successfully
Validation error - one or more required fields are missing or invalid
User with the specified ID does not exist
An unexpected error occurred
Example Request
curl -X PUT http://localhost:8080/api/v1/users/0f4df2de-fffb-4a24-9891-381ecf4f0f87 \
-H 'Content-Type: application/json' \
-d '{
"email": "jdoe@jdoe.com",
"firstName": "Jane",
"lastName": "Doe II",
"role": "ADMIN",
"active": true
}'
Example Response
{
"id": "0f4df2de-fffb-4a24-9891-381ecf4f0f87",
"username": "jdoe",
"email": "jdoe@jdoe.com",
"firstName": "Jane",
"lastName": "Doe II",
"role": "ADMIN",
"createdAt": "2024-01-15T10:30:00",
"updatedAt": "2024-01-15T10:35:00",
"active": true
}
Error Response Examples
Validation Error (400)
{
"type": "about:blank",
"title": "Validation Failed",
"status": 400,
"detail": "email: email must be a valid email address; firstName: first_name is required",
"timestamp": "2024-01-15T10:30:00"
}
User Not Found (404)
{
"type": "about:blank",
"title": "User Not Found",
"status": 404,
"detail": "User not found with id: 0f4df2de-fffb-4a24-9891-381ecf4f0f87",
"userId": "0f4df2de-fffb-4a24-9891-381ecf4f0f87",
"timestamp": "2024-01-15T10:30:00"
}
Notes
- The
username field is immutable and cannot be changed after user creation
- The
updatedAt timestamp is automatically updated when changes are made
- Setting
active to false deactivates the user account without deleting it