Skip to main content

POST /api/login

Authenticates a user with their email and password. Upon successful login, returns an authentication token that can be used for subsequent API requests.
This endpoint does not require authentication. The returned token should be stored securely and included in the Authorization header for protected endpoints.

Request body

email
string
required
Email address of the user account.Validation rules:
  • Must be a valid email format
password
string
required
Password for the user account.

Response

token
string
Authentication token for the user. Use this token in the Authorization header as Bearer {token} for authenticated requests.
token_type
string
The type of token issued. Always returns “Bearer”.
user
object
The authenticated user object.
user.id
integer
Unique identifier for the user.
user.name
string
Full name of the user.
user.email
string
Email address of the user.
user.created_at
string
Timestamp when the user account was created (ISO 8601 format).
user.updated_at
string
Timestamp when the user account was last updated (ISO 8601 format).

Error responses

422 Unprocessable Entity - Authentication failed. Common causes:
  • Email or password is incorrect
  • Required fields are missing
  • Email format is invalid

Example request

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

Example response

200 OK
{
  "token": "2|XyZ9876543210AbCdEfGhIjKlMnOpQrStUv",
  "token_type": "Bearer",
  "user": {
    "id": 42,
    "name": "John Doe",
    "email": "[email protected]",
    "created_at": "2024-03-15T10:30:00.000000Z",
    "updated_at": "2024-03-15T10:30:00.000000Z"
  }
}
422 Unprocessable Entity
{
  "message": "The provided credentials are incorrect.",
  "errors": {
    "email": [
      "The provided credentials are incorrect."
    ]
  }
}

Build docs developers (and LLMs) love