Skip to main content
POST
/
users
curl -X POST https://api.library.com/users \
  -u username:password \
  -H "Content-Type: application/json" \
  -d '{
    "firstname": "John",
    "lastname": "Doe",
    "email": "[email protected]",
    "password": "securePassword123"
  }'
{
  "201": {},
  "400": {},
  "401": {},
  "409": {},
  "id": 123,
  "firstname": "<string>",
  "lastname": "<string>",
  "email": "<string>",
  "borrowedBooks": [
    {
      "id": 123,
      "user": {},
      "book": {},
      "loanDate": "<string>",
      "returnDate": "<string>",
      "returned": true
    }
  ],
  "googleId": "<string>",
  "displayPicture": "<string>"
}

Authentication

This endpoint requires HTTP Basic Authentication.

Request Body

firstname
string
The user’s first name
lastname
string
The user’s last name
email
string
required
The user’s email address. Must be unique.
password
string
The user’s password. Will be encrypted before storage.
googleId
string
Optional Google OAuth ID for users signing in with Google
displayPicture
string
URL to the user’s display picture

Response

id
long
Unique identifier for the user
firstname
string
The user’s first name
lastname
string
The user’s last name
email
string
The user’s email address
borrowedBooks
array
Set of rental records for books borrowed by this user
googleId
string
Google OAuth ID (only included if set)
displayPicture
string
URL to the user’s display picture (only included if set)

Status Codes

201
Created
User successfully created
400
Bad Request
Invalid request body or missing required fields
401
Unauthorized
Missing or invalid authentication credentials
409
Conflict
Email address already exists
curl -X POST https://api.library.com/users \
  -u username:password \
  -H "Content-Type: application/json" \
  -d '{
    "firstname": "John",
    "lastname": "Doe",
    "email": "[email protected]",
    "password": "securePassword123"
  }'

Build docs developers (and LLMs) love