Skip to main content
PUT
/
api
/
v1
/
users
/
update
/
{id}
Update User
curl --request PUT \
  --url https://api.example.com/api/v1/users/update/{id} \
  --header 'Content-Type: application/json' \
  --data '
{
  "userName": "<string>",
  "name": "<string>",
  "birthDate": "<string>",
  "bookIds": [
    {}
  ]
}
'
{
  "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"
  ]
}
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

id
string
required
The unique identifier (UUID) of the user to update

Request Body

userName
string
required
Username for the user’s account
name
string
required
Full name of the user
birthDate
string
required
Date of birth in ISO 8601 format (YYYY-MM-DD)
bookIds
array
required
Array of book UUIDs to be associated with this user. This replaces the existing book collection.

Response

id
string
Unique identifier of the user (UUID format)
userName
string
Updated username for the user’s account
name
string
Updated full name of the user
birthDate
string
Updated date of birth in ISO 8601 format (YYYY-MM-DD)
bookIds
array
Updated array of book UUIDs associated with this user

Example Request

cURL
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

CodeDescription
200Successfully updated user
400Bad request - Invalid user data or UUID format
401Unauthorized - Invalid or missing JWT token
404User not found
500Internal 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

Build docs developers (and LLMs) love