Skip to main content
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

  1. Employee submits email and password
  2. System validates credentials against the database
  3. Checks if employee status is “active”
  4. Verifies password hash using bcrypt
  5. Generates JWT token with 24-hour expiration
  6. Returns token with employee and company details

Request

string
required
Employee email address. Must be a valid email format.Example: john.doe@company.com
string
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 probation
string
Employment type: full_time, part_time, contract, or intern
string
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 inactive
object
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.
Common causes:
  • Missing email or password field
  • Invalid JSON format
  • Email not in valid format

401 Unauthorized

Returned when the credentials are invalid or the employee account is not active.
Common causes:
  • 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.
Common causes:
  • 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 UUID
  • role: Employee role name
  • company_id: Company UUID
  • email: Employee email
  • first_name: Employee first name
  • last_name: Employee last name
  • sub: Subject (employee ID)
  • iat: Issued at timestamp
  • exp: Expiration timestamp (24 hours from issuance)
The token is signed using HS256 algorithm with the JWT_SECRET environment variable.

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