Skip to main content

POST /api/auth/login

Authenticate a user with their email and password. Returns user information upon successful authentication.

Authentication

No authentication required.

Request body

email
string
required
Email address of the registered user
password
string
required
User password for authentication

Response

id
string
Unique user identifier
name
string
Full name of the authenticated user
email
string
Email address of the authenticated user
role
string
User role (company or candidate)

Example request

curl -X POST https://api.fairmatch.ai/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123"
  }'
{
  "email": "[email protected]",
  "password": "securePassword123"
}

Example response

{
  "id": "a3f8c2d1",
  "name": "Jane Smith",
  "email": "[email protected]",
  "role": "candidate"
}

Status codes

200
Success
User successfully authenticated
401
Error
Invalid password provided
{
  "detail": "Invalid password"
}
404
Error
User not found with the provided email
{
  "detail": "User not found"
}

Implementation details

  • Passwords are verified using bcrypt comparison
  • Passwords are truncated to 72 bytes before verification (matching registration behavior)
  • Authentication is stateless - consider implementing session tokens for production use

Build docs developers (and LLMs) love