Skip to main content
POST
/
api
/
auth
/
login
Login
curl --request POST \
  --url https://api.example.com/api/auth/login \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "password": "<string>"
}
'
{
  "success": true,
  "data": {
    "user": {
      "id": "<string>",
      "email": "<string>",
      "fullName": "<string>",
      "phone": {},
      "avatar": {},
      "emailVerified": true
    },
    "accessToken": "<string>",
    "refreshToken": "<string>"
  }
}
Authenticates a user with their email and password credentials. Returns the user profile along with access and refresh tokens. Updates the user’s last login timestamp.

Request Body

email
string
required
User’s email address. Must be a valid email format.
password
string
required
User’s password. Required field.

Response

success
boolean
Indicates if the request was successful.
data
object
Contains the authentication result.

Error Responses

401 Unauthorized
Invalid email or password credentials.
{
  "success": false,
  "error": {
    "message": "Invalid credentials",
    "statusCode": 401
  }
}
403 Forbidden
User account is disabled.
{
  "success": false,
  "error": {
    "message": "Account is disabled",
    "statusCode": 403
  }
}
400 Bad Request
Invalid request body or validation error.
{
  "success": false,
  "error": {
    "message": "Validation error",
    "statusCode": 400,
    "details": []
  }
}

Example Request

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

Example Response

{
  "success": true,
  "data": {
    "user": {
      "id": "clx1234567890abcdef",
      "email": "[email protected]",
      "fullName": "John Doe",
      "phone": "+1234567890",
      "avatar": null,
      "emailVerified": false
    },
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "rt_clx1234567890abcdef"
  }
}

Build docs developers (and LLMs) love