Skip to main content
POST
/
auth
/
login
Login User
curl --request POST \
  --url https://api.example.com/auth/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "password": "<string>"
}
'
{
  "200": {},
  "401": {}
}

Endpoint

POST /auth/login
Authenticate a user using their email and password. The endpoint validates the credentials and returns a success message if authentication is successful.

Authentication

No authentication required (this endpoint provides authentication).

Request Body

email
string
required
User’s registered email address
password
string
required
User’s password

Response

Returns a plain text string message indicating the result of the login attempt.

Status Codes

200
OK
Login successful. Returns message: “Login successful”
401
Unauthorized
Invalid credentials. Returns error message: “Invalid email or password”

Example Request

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

Example Response

Success (200 OK)

Login successful

Error (401 Unauthorized)

Invalid email or password

Notes

  • Passwords are validated using BCrypt encryption
  • The endpoint checks both if the email exists and if the password matches
  • Both invalid email and invalid password return the same error message for security reasons (prevents email enumeration attacks)

Build docs developers (and LLMs) love