Skip to main content
DELETE
/
api
/
v1
/
users
/
{userId}
/
books
/
{bookId}
Remove Book from User
curl --request DELETE \
  --url https://api.example.com/api/v1/users/{userId}/books/{bookId}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "userName": "jsmith",
  "name": "John Smith",
  "birthDate": "1990-05-15",
  "bookIds": [
    "9f3e4a56-2c1d-4b8e-8f6d-5a3c2b1d4e5f"
  ]
}
This endpoint removes the association between a user and a book, removing the book from the user’s personal collection.

Authentication

This endpoint requires JWT authentication. Include a valid JWT token in the Authorization header.
Authorization: Bearer <your_jwt_token>

Path Parameters

userId
string
required
The unique identifier (UUID) of the user
bookId
string
required
The unique identifier (UUID) of the book to remove from the user’s collection

Response

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

Example Request

cURL
curl -X DELETE "https://api.library.com/api/v1/users/550e8400-e29b-41d4-a716-446655440000/books/7c9e6679-7425-40de-944b-e07fc1f90ae7" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "userName": "jsmith",
  "name": "John Smith",
  "birthDate": "1990-05-15",
  "bookIds": [
    "9f3e4a56-2c1d-4b8e-8f6d-5a3c2b1d4e5f"
  ]
}

Status Codes

CodeDescription
200Successfully removed book from user’s collection
400Bad request - Invalid UUID format
401Unauthorized - Invalid or missing JWT token
404User or book not found
500Internal server error

Notes

  • This endpoint removes the many-to-many relationship between the user and the book
  • Removing a book from a user’s collection does not delete the book from the system
  • If the book is not in the user’s collection, the operation is idempotent (no error thrown)
  • The response includes the complete updated user object with remaining associated book IDs
  • Both the user and the book must exist in the system

Build docs developers (and LLMs) love