Login User

Authenticates a user with either their email or username plus password, and returns a JWT valid for 7 days.

Endpoint

POST {{base_url}}/v1/auth/login

Headers

HeaderValue
Content-Typeapplication/json

This endpoint does not require authentication — it's used to obtain a token.


Body Parameters

ParameterTypeRequiredDescription
email_or_usernamestringYesYour account's email address or username. If the value looks like an email (contains @ and a domain), it's matched against email; otherwise it's matched against username.
passwordstringYesYour account password.

Example Request

{
  "email_or_username": "johndoe",
  "password": "Strong@123"
}
curl --location '{{base_url}}/v1/auth/login' \
--header 'Content-Type: application/json' \
--data '{
    "email_or_username": "johndoe",
    "password": "Strong@123"
}'

Example Response — 200 OK

{
  "success": true,
  "message": "Login successful",
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 42,
    "username": "johndoe",
    "email": "[email protected]",
    "mobile_no": "919876543210",
    "firstname": "John",
    "lastname": "Doe",
    "name": "John Doe",
    "user_type": "client",
    "role": "user",
    "api_base_url": null
  }
}

Response Fields

FieldDescription
successtrue on a successful login.
messageHuman-readable confirmation.
tokenJWT to use as Authorization: Bearer <token> on subsequent requests. Valid for 7 days.
user.idInternal account ID (admin_id).
user.usernameAccount username.
user.emailAccount email, or null if not set.
user.mobile_noAccount mobile number, or null if not set.
user.firstname / user.lastnameAccount name fields.
user.nameFull name (firstname + lastname, trimmed).
user.user_typeAccount type (e.g. client), or null.
user.roleDerived role — super, admin, or user (see Role Derivation below).
user.api_base_urlAccount's configured API base URL, or null if not set.

Validation Rules

  • Both email_or_username and password are required.
  • The account looked up must be active (is_active = 0 — see Notes on this flag's meaning).
  • If the account has an expiry date set, today's date must not be past it.
  • The provided password must match the account's stored password hash.

Error Responses

StatusMessageReason
400Missing email_or_username or passwordOne or both fields not provided.
401Invalid credentialsNo account found for the given email/username, or password doesn't match.
401Account is inactiveThe matched account is not active.
401Account expired. Please contact your administrator.The account's expiry date has passed.

Notes

  • Password hash compatibility: Password hashes are compared using bcrypt. Hashes stored with a $2y$ prefix (common from PHP/Laravel) are normalized to $2a$ before comparison, so accounts migrated from PHP-based systems continue to work.