Skip to main content
PUT
/
books
/
{isbn}
Create or Update Book
curl --request PUT \
  --url https://api.example.com/books/{isbn} \
  --header 'Content-Type: application/json' \
  --data '
{
  "isbn": "<string>",
  "title": "<string>",
  "author": {
    "author.id": 123,
    "author.name": "<string>",
    "author.age": 123
  },
  "stock": 123,
  "coverImage": "<string>"
}
'
{
  "isbn": "<string>",
  "title": "<string>",
  "author": {
    "author.id": 123,
    "author.name": "<string>",
    "author.age": 123
  },
  "stock": 123,
  "coverImage": "<string>"
}
Create a new book or update an existing book by ISBN. This endpoint performs an upsert operation - if the book exists, it will be updated; if not, it will be created.

Authentication

This endpoint requires HTTP Basic Authentication.

Path Parameters

isbn
string
required
The ISBN of the book. This is used as the unique identifier for the book.

Request Body

isbn
string
required
The ISBN of the book. Should match the path parameter.
title
string
required
The title of the book.
author
object
required
The author information for the book.
author.id
integer
The unique identifier of the author.
author.name
string
required
The name of the author.
author.age
integer
The age of the author.
stock
integer
required
The number of copies available in stock.
coverImage
string
URL or path to the book’s cover image. This field is optional.

Response

isbn
string
The ISBN of the book.
title
string
The title of the book.
author
object
The author information.
author.id
integer
The unique identifier of the author.
author.name
string
The name of the author.
author.age
integer
The age of the author.
stock
integer
The number of copies available in stock.
coverImage
string
URL or path to the book’s cover image. Only included if set.

Status Codes

  • 200 OK: Book was successfully updated
  • 201 Created: Book was successfully created
  • 401 Unauthorized: Authentication credentials are missing or invalid

Example Request

curl -X PUT https://api.example.com/books/978-0-7475-3269-9 \
  -u username:password \
  -H "Content-Type: application/json" \
  -d '{
    "isbn": "978-0-7475-3269-9",
    "title": "Harry Potter and the Philosopher Stone",
    "author": {
      "id": 1,
      "name": "J.K. Rowling",
      "age": 58
    },
    "stock": 15,
    "coverImage": "https://example.com/covers/hp1.jpg"
  }'

Example Response

{
  "isbn": "978-0-7475-3269-9",
  "title": "Harry Potter and the Philosopher Stone",
  "author": {
    "id": 1,
    "name": "J.K. Rowling",
    "age": 58
  },
  "stock": 15,
  "coverImage": "https://example.com/covers/hp1.jpg"
}

Notes

  • This is a full update operation (PUT). All fields must be provided in the request body.
  • If you want to update only specific fields, use the Partial Update endpoint instead.
  • The author cascade operation means the author will be created or updated along with the book.

Build docs developers (and LLMs) love