POST /api/v1/auth/login

Authenticate a user with email and password. Returns access token and refresh token for subsequent API calls. Supports all user roles (Student, Lecturer, Admin).

application/json

Body Required

User login credentials

  • email string Required
  • password string Required

Responses

  • 201 application/json

    Login successful. Returns access token and refresh token.

    Hide response attributes Show response attributes object
    • message string Required
    • access_token string Required
    • refresh_token string Required
  • 400 application/json

    Invalid login credentials or validation errors

  • 401 application/json

    Invalid email or password

  • 500 application/json

    Internal server error during authentication

POST /api/v1/auth/login
curl \
 --request POST 'http://localhost:3500/api/v1/auth/login' \
 --header "Content-Type: application/json" \
 --data '{"email":"student@university.edu","password":"securePassword123"}'
Request examples
Example login for a student user
{
  "email": "student@university.edu",
  "password": "securePassword123"
}
Example login for a lecturer user
{
  "email": "lecturer@university.edu",
  "password": "lecturerPassword456"
}
Example login for an admin user
{
  "email": "admin@university.edu",
  "password": "adminPassword789"
}
Response examples (201)
{
  "message": "Login successful",
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Response examples (400)
{
  "error": "Bad Request",
  "message": [
    "email must be an email",
    "password should not be empty"
  ],
  "statusCode": 400
}
Response examples (401)
{
  "error": "Unauthorized",
  "message": "Invalid credentials",
  "statusCode": 401
}
Response examples (500)
{
  "error": "Internal Server Error",
  "message": "Internal server error",
  "statusCode": 500
}