library-rest
Partially update a book.
PATCH
/books/{id}Applies only the fields present in the request body; omitted fields are left unchanged. The book's status cannot be changed here — it only changes via POST /loans (borrow) and POST /loans/{id}/return, so it always reflects a real open loan.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | yes | The book's unique identifier. |
Request body
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| authorId | string | The id of a different existing Author to reassign this book to. | |
| isbn | string | The book's new ISBN. Must be unique across the catalog. | |
| publishedYear | integer | The book's new published year. Must be between 1450 and next year. | |
| title | string | The book's new display title, 1–200 characters. |
Responses
200 The updated book.
application/json
| Field | Type | Required | Description |
|---|---|---|---|
| data | object | yes | A single library title. |
| authorId | string | yes | The id of the Author who wrote this book. |
| createdAt | string (date-time) | yes | When the book record was created. |
| id | string | yes | Unique identifier assigned by the server, prefixed with bk_. |
| isbn | string | yes | The book's ISBN. Must be unique across the catalog. |
| publishedYear | integer | yes | The year the book was first published. Must be between 1450 and next year. |
| status | string | yes | A book's availability. borrowed means it is out on an open loan. Allowed values: available, borrowed |
| title | string | yes | The book's display title, 1–200 characters. |
| updatedAt | string (date-time) | yes | When the book record was last modified. |
| meta | object | yes | Response metadata attached to every successful response. |
| requestId | string | yes | Correlation id for this request, echoed from the X-Request-Id request header or generated if absent. Useful for tracing a request across logs. |
| total | integer | Total number of matches before pagination was applied. Present only on paginated list responses (currently GET /books). |
Errors
| Code | Message | Description |
|---|---|---|
| 400 | The request body is not valid JSON. | |
| 401 | The request is missing a valid Authorization: Bearer <token> header. | |
| 404 | The book does not exist, or the new authorId does not reference an existing author. | |
| 409 | The new isbn is already used by another book. | |
| 415 | The request has a body but its Content-Type is not application/json. | |
| 422 | A supplied field failed validation (e.g. a blank title, or publishedYear out of range). | |
| 500 | An unexpected error occurred. The response never leaks internal error details. |
Request example
{
"authorId": "authorId_868",
"isbn": "isbn_184",
"publishedYear": 637,
"title": "title_134"
}Response example
{
"data": {
"authorId": "authorId_163",
"createdAt": "createdAt_114",
"id": "id_545",
"isbn": "isbn_884",
"publishedYear": 141,
"status": "available",
"title": "title_605",
"updatedAt": "updatedAt_134"
},
"meta": {
"requestId": "requestId_523",
"total": 351
}
}