This endpoint allows you to update a user’s personal information and their associated book collection.
Authentication
This endpoint requires JWT authentication. Include a valid JWT token in the Authorization header.
Authorization: Bearer <your_jwt_token>
Path Parameters
The unique identifier (UUID) of the user to update
Request Body
Username for the user’s account
Date of birth in ISO 8601 format (YYYY-MM-DD)
Array of book UUIDs to be associated with this user. This replaces the existing book collection.
Response
Unique identifier of the user (UUID format)
Updated username for the user’s account
Updated full name of the user
Updated date of birth in ISO 8601 format (YYYY-MM-DD)
Updated array of book UUIDs associated with this user
Example Request
curl -X PUT "https://api.library.com/api/v1/users/update/550e8400-e29b-41d4-a716-446655440000" \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"userName": "jsmith_updated",
"name": "John Alexander Smith",
"birthDate": "1990-05-15",
"bookIds": [
"7c9e6679-7425-40de-944b-e07fc1f90ae7",
"9f3e4a56-2c1d-4b8e-8f6d-5a3c2b1d4e5f",
"3d8f5b2a-1e4c-6d7f-9a0b-8c7e6d5f4a3b"
]
}'
Example Response
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"userName": "jsmith_updated",
"name": "John Alexander Smith",
"birthDate": "1990-05-15",
"bookIds": [
"7c9e6679-7425-40de-944b-e07fc1f90ae7",
"9f3e4a56-2c1d-4b8e-8f6d-5a3c2b1d4e5f",
"3d8f5b2a-1e4c-6d7f-9a0b-8c7e6d5f4a3b"
]
}
Status Codes
| Code | Description |
|---|
| 200 | Successfully updated user |
| 400 | Bad request - Invalid user data or UUID format |
| 401 | Unauthorized - Invalid or missing JWT token |
| 404 | User not found |
| 500 | Internal server error |
Notes
- All fields in the request body are required
- The
bookIds array replaces the entire existing collection - it does not append to it
- If you need to add or remove individual books, use the dedicated endpoints:
/api/v1/users/{userId}/books/{bookId}
- The user’s UUID cannot be changed