Authentication
Login
Authenticate user and return JWT token
POST
Login
Overview
The login endpoint authenticates employees using their email and password credentials. Upon successful authentication, it returns a JWT token valid for 24 hours along with employee and company information.Authentication Flow
- Employee submits email and password
- System validates credentials against the database
- Checks if employee status is “active”
- Verifies password hash using bcrypt
- Generates JWT token with 24-hour expiration
- Returns token with employee and company details
Request
string
required
Employee email address. Must be a valid email format.Example:
john.doe@company.comstring
required
Employee password. Minimum 8 characters required.Example:
SecurePass123!Request Example
Response
boolean
Indicates if the request was successful
object
Contains the authentication response data
string
JWT authentication token valid for 24 hours. Use this token in the Authorization header for subsequent API requests.
string
Employee’s role name (e.g., “admin”, “manager”, “employee”)
object
Employee details
string
Employee UUID
string
Company UUID
string
Employee email address
string
Employee phone number
string
Employee first name
string
Employee last name
string
Internal employee code (e.g., “EMP001”)
string
Department UUID
string
Designation UUID
string
Level UUID
string
Manager’s employee UUID (if applicable)
string
Role UUID
string
Employee status:
active, inactive, on_leave, terminated, or probationstring
Employment type:
full_time, part_time, contract, or internstring
Date of birth in ISO 8601 format
string
Hire date in ISO 8601 format
string
Termination date in ISO 8601 format (if applicable)
string
Employee gender
string
Employee address
string
Emergency contact name
string
Emergency contact phone number
string
Profile image URL
string
Last login timestamp in ISO 8601 format
string
Account creation timestamp in ISO 8601 format
string
Last update timestamp in ISO 8601 format
object
Company details
string
Company UUID
string
Company name
string
Company slug (URL-friendly identifier)
string
Company industry
string
Company country
string
Company timezone
string
Company currency code
string
Company registration number
string
Company tax ID
string
Company address
string
Company phone number
string
Company logo URL
string
Company status:
active, suspended, or inactiveobject
Company-specific settings (JSON blob)
string
Company creation timestamp in ISO 8601 format
string
Last update timestamp in ISO 8601 format
Success Response Example
Error Responses
400 Bad Request
Returned when the request body is malformed or missing required fields.- Missing
emailorpasswordfield - Invalid JSON format
- Email not in valid format
401 Unauthorized
Returned when the credentials are invalid or the employee account is not active.- Incorrect email or password
- Employee not found in database
- Employee status is not “active” (e.g., inactive, terminated, on_leave, probation)
- Password hash verification failed
500 Internal Server Error
Returned when an unexpected server error occurs.- Database connection failure
- JWT token generation failure
- Missing JWT_SECRET environment variable
JWT Token Details
The returned JWT token contains the following claims:employee_id: Employee UUIDrole: Employee role namecompany_id: Company UUIDemail: Employee emailfirst_name: Employee first namelast_name: Employee last namesub: Subject (employee ID)iat: Issued at timestampexp: Expiration timestamp (24 hours from issuance)
Usage Example
cURL
JavaScript (fetch)
Python (requests)
Using the Token
After successful login, include the JWT token in the Authorization header for subsequent API requests:Security Notes
- Passwords are hashed using bcrypt with default cost factor
- JWT tokens expire after 24 hours
- Only employees with “active” status can login
- Failed login attempts do not reveal whether the email exists
- Tokens should be stored securely (e.g., httpOnly cookies or secure storage)
- Always use HTTPS in production to protect credentials in transit