HRIS API Documentation

RESTful API for integrating HRIS with external systems, biometric devices, and third-party applications.

Base URL: http://localhost/HRIS/api Version: v1

Authentication

All API endpoints require authentication using JWT tokens. Include the token in the Authorization header:

Authorization: Bearer {your_jwt_token}

Login Endpoint

POST /api/auth/login

Request Body:

{
    "email": "user@example.com",
    "password": "your_password"
}

Response:

{
    "success": true,
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "user": {
        "id": 1,
        "email": "user@example.com",
        "role": "employee"
    }
}

Employees API

GET /api/employees

Get list of all employees (requires admin role)

Query Parameters: page, per_page, department_id, status

GET /api/employees/{id}

Get employee details by ID

POST /api/employees

Create new employee (requires admin role)

{
    "employee_number": "EMP-001",
    "first_name": "John",
    "last_name": "Doe",
    "email": "john.doe@example.com",
    "department_id": 1,
    "position_id": 1,
    "hire_date": "2024-01-15",
    "salary_rate": 35000.00,
    "salary_type": "monthly"
}
PUT /api/employees/{id}

Update employee information (requires admin role)

DELETE /api/employees/{id}

Delete employee (requires super admin role)

Attendance API

POST /api/attendance/clock-in

Clock in for the day

{
    "employee_id": 1,
    "timestamp": "2024-01-15 08:00:00"
}
POST /api/attendance/clock-out

Clock out for the day

{
    "employee_id": 1,
    "timestamp": "2024-01-15 17:00:00"
}
GET /api/attendance

Get attendance records

Query Parameters: employee_id, start_date, end_date, page, per_page

Leave API

GET /api/leaves

Get leave requests

Query Parameters: employee_id, status, start_date, end_date

POST /api/leaves

Create leave request

{
    "employee_id": 1,
    "leave_type_id": 1,
    "start_date": "2024-02-01",
    "end_date": "2024-02-03",
    "reason": "Family vacation"
}
PUT /api/leaves/{id}/status

Approve or reject leave request (requires supervisor/HR role)

{
    "status": "approved",
    "remarks": "Approved"
}

Payroll API

GET /api/payroll/runs

Get payroll runs (requires HR admin role)

POST /api/payroll/runs

Create new payroll run (requires HR admin role)

{
    "name": "January 2024 Payroll",
    "period_start": "2024-01-01",
    "period_end": "2024-01-15",
    "payroll_date": "2024-01-20"
}
GET /api/payslips

Get payslips for employee

Query Parameters: employee_id, start_date, end_date

Error Responses

All error responses follow this format:

{
    "success": false,
    "error": {
        "code": "ERROR_CODE",
        "message": "Error description"
    }
}

Common Error Codes

401 Unauthorized - Invalid or missing token
403 Forbidden - Insufficient permissions
404 Not Found - Resource doesn't exist
422 Validation Error - Invalid input data
500 Internal Server Error