Skip to main content

API Overview

The HRMS backend exposes a RESTful JSON API built with Laravel 12. All endpoints follow consistent conventions for authentication, response format, and error handling.

Interactive API Documentation

The HRMS uses Scramble to auto-generate interactive API documentation from the codebase.

Accessing Scramble Docs

When the backend is running locally:

Scramble reads the route definitions, FormRequest validation rules, and API Resource transformations to generate up-to-date documentation automatically.

note

Scramble docs are only available in non-production environments by default. Check config/scramble.php for configuration.

Base URL

http://localhost:8000/api

All API endpoints are prefixed with /api.

Authentication

The API uses Laravel Sanctum with cookie-based session authentication.

Login Flow

# 1. Get CSRF token
GET /sanctum/csrf-cookie

# 2. Sign in
POST /api/login
Content-Type: application/json

{
"email": "admin@kingrevolution.com",
"password": "password"
}

# 3. Subsequent requests include session cookie automatically
GET /api/employees

Key Headers

HeaderValueWhen
Acceptapplication/jsonAlways
Content-Typeapplication/jsonPOST/PUT requests
X-XSRF-TOKENFrom XSRF-TOKEN cookieAll mutating requests
RefererFrontend URLAll requests

See Authentication for full details.

Response Format

All API responses follow a consistent envelope format:

Success Response

{
"data": { ... },
"message": "Operation successful"
}

Paginated Response

{
"data": [ ... ],
"links": {
"first": "http://localhost:8000/api/employees?page=1",
"last": "http://localhost:8000/api/employees?page=5",
"prev": null,
"next": "http://localhost:8000/api/employees?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 5,
"per_page": 15,
"to": 15,
"total": 73
}
}

Error Response

{
"message": "The given data was invalid.",
"errors": {
"email": ["The email field is required."],
"employee_number": ["The employee number has already been taken."]
}
}

HTTP Status Codes

CodeMeaning
200OK — Successful GET, PUT
201Created — Successful POST
204No Content — Successful DELETE
401Unauthorized — Not logged in
403Forbidden — Insufficient permissions
404Not Found — Resource doesn't exist
422Validation Error — Invalid request data
429Too Many Requests — Rate limited
500Server Error — Unexpected failure

Pagination

List endpoints support pagination via query parameters:

ParameterDefaultDescription
page1Page number
per_page15Items per page (max 100)
GET /api/employees?page=2&per_page=25

Search & Filtering

GET /api/employees?search=john

Searches across relevant text fields (name, email, employee number).

Filtering

GET /api/employees?entity_id=1&department_id=3&activity_status=active

Ordering

GET /api/employees?sort_by=last_name&sort_direction=asc

Endpoint Groups

GroupBase PathDescription
Authentication/api/login, /api/logout, /api/userSession management
Entities/api/entitiesCompany/entity management
Departments/api/departmentsDepartment CRUD + manager/lead assignment
Employees/api/employeesEmployee CRUD, import, export, attachments
KPI Templates/api/kpi-templatesTemplate CRUD + import
KPI Cycles/api/kpi-cyclesCycle CRUD + publish + export
KPI Evaluations/api/kpi-evaluationsEvaluation workflow endpoints
Probation Reviews/api/probation-reviewsProbation review workflow
Notifications/api/notificationsUser notifications
Notification Settings/api/notification-settingsAdmin notification config
Roles & Permissions/api/roles, /api/permissionsRBAC management
Actionable Items/api/actionable-itemsUser task queue
Dashboard/api/dashboardSummary statistics
Profile/api/profileCurrent user profile management

See Endpoint Reference for the complete endpoint listing.