Skip to main content
POST
/
books
/
{isbn}
/
user
/
{user_id}
curl -X POST https://api.example.com/books/978-0-12345-678-9/user/42 \
  -u "username:password" \
  -H "Content-Type: application/json"
{
  "id": 123,
  "user": {
    "id": 42,
    "firstname": "John",
    "lastname": "Doe",
    "email": "[email protected]",
    "displayPicture": "https://example.com/photos/john.jpg"
  },
  "book": {
    "isbn": "978-0-12345-678-9",
    "title": "The Great Adventure",
    "stock": 4,
    "coverImage": "https://example.com/covers/great-adventure.jpg",
    "author": {
      "id": 7,
      "name": "Jane Smith",
      "age": 45
    }
  },
  "loanDate": "2026-03-04T10:30:00Z",
  "returnDate": "2026-03-18T10:30:00Z",
  "returned": false
}

Authentication

This endpoint requires HTTP Basic Authentication.

Path Parameters

isbn
string
required
The ISBN of the book to rent
user_id
integer
required
The ID of the user renting the book

Response

id
integer
Unique identifier for the rental
user
object
User who rented the book
id
integer
User ID
firstname
string
User’s first name
lastname
string
User’s last name
email
string
User’s email address
displayPicture
string
URL to user’s display picture
book
object
Book being rented
isbn
string
Book ISBN
title
string
Book title
stock
integer
Current stock count (decremented by 1 after rental)
coverImage
string
URL to book cover image
author
object
Book author details
id
integer
Author ID
name
string
Author name
age
integer
Author age
loanDate
string
ISO 8601 timestamp when the book was rented (UTC)
returnDate
string
ISO 8601 timestamp when the book is due (2 weeks from loan date)
returned
boolean
Whether the book has been returned (always false for new rentals)

Error Responses

404
error
Book with the specified ISBN or user with the specified ID not found
400
error
Book is out of stock (stock = 0)

Automatic Stock Management

When a rental is created, the book’s stock is automatically decremented by 1. If the book has no stock available (stock = 0), the request will fail with a 400 Bad Request error.

Loan Period

All rentals have a 2-week loan period. The returnDate is automatically set to 2 weeks (14 days) from the loanDate.
curl -X POST https://api.example.com/books/978-0-12345-678-9/user/42 \
  -u "username:password" \
  -H "Content-Type: application/json"
{
  "id": 123,
  "user": {
    "id": 42,
    "firstname": "John",
    "lastname": "Doe",
    "email": "[email protected]",
    "displayPicture": "https://example.com/photos/john.jpg"
  },
  "book": {
    "isbn": "978-0-12345-678-9",
    "title": "The Great Adventure",
    "stock": 4,
    "coverImage": "https://example.com/covers/great-adventure.jpg",
    "author": {
      "id": 7,
      "name": "Jane Smith",
      "age": 45
    }
  },
  "loanDate": "2026-03-04T10:30:00Z",
  "returnDate": "2026-03-18T10:30:00Z",
  "returned": false
}

Build docs developers (and LLMs) love