The Universal Bookshelf API uses JWT (JSON Web Tokens) for authentication. All protected endpoints require a valid JWT token in the Authorization header.
https://yourdomain.com/api
Register a new user account
{
"name": "John Doe",
"email": "[email protected]",
"password": "password123",
"password_confirmation": "password123",
"role": "reader"
}
{
"status": true,
"message": "User successfully registered",
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"role": "reader",
"email_verified_at": null,
"created_at": "2024-01-01T00:00:00.000000Z",
"updated_at": "2024-01-01T00:00:00.000000Z"
},
"authorization": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"type": "bearer"
}
}
{
"status": false,
"message": "Validation error",
"errors": {
"email": ["The email has already been taken."],
"password": ["The password confirmation does not match."]
}
}
Authenticate user and receive JWT token
{
"email": "[email protected]",
"password": "password123"
}
{
"status": true,
"message": "Login successful",
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"role": "reader"
},
"authorization": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"type": "bearer"
}
}
{
"status": false,
"message": "Invalid credentials"
}
Logout user and invalidate token
Authorization: Bearer <your_jwt_token>
{
"status": true,
"message": "Successfully logged out"
}
Refresh JWT token
Authorization: Bearer <your_jwt_token>
{
"status": true,
"message": "Token refreshed successfully",
"authorization": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"type": "bearer"
}
}
Get authenticated user's profile information
Authorization: Bearer <your_jwt_token>
{
"status": true,
"user": {
"id": 1,
"name": "John Doe",
"email": "[email protected]",
"role": "reader",
"email_verified_at": "2024-01-01T00:00:00.000000Z",
"created_at": "2024-01-01T00:00:00.000000Z",
"updated_at": "2024-01-01T00:00:00.000000Z"
}
}
Update user profile information
Authorization: Bearer <your_jwt_token>
{
"name": "John Smith",
"email": "[email protected]"
}
{
"status": true,
"message": "Profile updated successfully",
"user": {
"id": 1,
"name": "John Smith",
"email": "[email protected]",
"role": "reader",
"updated_at": "2024-01-01T00:00:00.000000Z"
}
}
Change user password
Authorization: Bearer <your_jwt_token>
{
"current_password": "oldpassword123",
"new_password": "newpassword123",
"new_password_confirmation": "newpassword123"
}
{
"status": true,
"message": "Password changed successfully"
}
Resend email verification link
Authorization: Bearer <your_jwt_token>
{
"status": true,
"message": "Verification link sent!"
}
Authentication endpoints are limited to 5 requests per minute per IP address. Exceeding this limit will result in a 429 response.
For additional support or questions about authentication, please contact our development team.
Back to Documentation