Introduction
The Kontrak API is a REST API designed for generating employment contracts and processing employee data through Excel files. It provides endpoints for contract generation, Excel data processing, and addendum creation.Base URL
The API is accessible at:In production, replace
localhost:3000 with your deployed server URL.API Version
Current version: v1.0.0 The API follows a simple versioning approach. Version information is returned in the root health check endpoint.Request/Response Format
All API endpoints accept and return JSON data unless otherwise specified.Standard Response Structure
Successful responses follow this structure:Available Endpoints
The API is organized into three main resource groups:Contracts
Generate and preview employment contracts in PDF and ZIP formats
Excel Processing
Upload and process Excel files, generate specialized Excel reports
Addendum
Process addendum data from Excel files
Contract Endpoints
POST /api/contracts/download-zip- Generate and download contracts as ZIPPOST /api/contracts/preview- Preview a contract PDF
Excel Processing Endpoints
POST /api/excel/upload- Upload and process Excel file with employee dataPOST /api/excel/download-lawlife- Generate Law Life Excel reportPOST /api/excel/download-sctr- Generate SCTR Excel reportPOST /api/excel/download-photocheck- Generate photocheck/ID card Excel
Addendum Endpoints
POST /api/addendum/upload- Process Excel file to extract addendum data
Health Check
The API provides two health check endpoints:Root Health Check
API Health Check
File Upload Limits
The API enforces the following file upload limits:- Maximum file size: 10 MB (configurable via
MAX_FILE_SIZEenvironment variable) - Maximum files per request: 1
- Allowed file types:
.xlsx,.xls,.csv - Maximum employees per batch: 1,000 (configurable via
MAX_EMPLOYEESenvironment variable)
CORS Configuration
The API supports Cross-Origin Resource Sharing (CORS) for the following HTTP methods:GETPOSTPUTDELETEPATCH
CORS_ORIGINS environment variable (default: http://localhost:5173).
Error Handling
The API uses standard HTTP status codes:| Status Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid input or validation error |
404 | Not Found - Endpoint does not exist |
500 | Internal Server Error |
Validation Errors
Validation errors return detailed information about invalid fields:Rate Limiting
Currently, the API does not implement rate limiting. For production deployments, it is recommended to add rate limiting middleware to prevent abuse.
Next Steps
Authentication
Learn about API security and authentication
Contract Endpoints
Explore contract generation endpoints