Skip to main content
POST
/
auth
/
register
Register User
curl --request POST \
  --url https://api.example.com/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "firstname": "<string>",
  "lastname": "<string>",
  "email": "<string>",
  "password": "<string>",
  "googleId": "<string>",
  "displayPicture": "<string>"
}
'
{
  "201": {},
  "400": {},
  "id": 123,
  "firstname": "<string>",
  "lastname": "<string>",
  "email": "<string>",
  "borrowedBooks": [
    {}
  ],
  "displayPicture": "<string>"
}

Endpoint

POST /auth/register
Create a new user account in the library system. This endpoint validates that the email is not already in use before creating the account.

Authentication

No authentication required.

Request Body

firstname
string
required
User’s first name
lastname
string
required
User’s last name
email
string
required
User’s email address. Must be unique in the system.
password
string
required
User’s password. Will be encrypted before storage.
googleId
string
Optional Google OAuth ID for social login integration
displayPicture
string
Optional URL to user’s display picture

Response

id
long
Unique identifier for the created user
firstname
string
User’s first name
lastname
string
User’s last name
email
string
User’s email address
borrowedBooks
array
Array of rental records for books borrowed by the user (empty for new users)
displayPicture
string
URL to user’s display picture (if provided)

Status Codes

201
Created
User successfully created. Returns the created user object.
400
Bad Request
Email already in use. Returns error message: “Email already in use”

Example Request

curl -X POST https://api.example.com/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "firstname": "John",
    "lastname": "Doe",
    "email": "[email protected]",
    "password": "securePassword123"
  }'

Example Response

Success (201 Created)

{
  "id": 1,
  "firstname": "John",
  "lastname": "Doe",
  "email": "[email protected]",
  "borrowedBooks": []
}

Error (400 Bad Request)

Email already in use

Build docs developers (and LLMs) love