Generate Your First Contract
This guide will take you from zero to generating your first employment contract in under 10 minutes.Prerequisites Check
Before starting, ensure you have the following installed:
- Node.js: Version 18.0.0 or higher
- npm: Version 8.0.0 or higher (comes with Node.js)
- Git: For cloning the repository
Clone and Install
Clone the repository and install dependencies:This will install all required packages including Express, TypeScript, Puppeteer, and Zod.
Start the Development Server
Start the server in development mode:You should see output similar to:
The server uses
nodemon and ts-node in development mode, which automatically restarts on file changes.Verify Installation
Test that the API is running by hitting the health check endpoint:Expected response:
Generate Your First Contract
Now let’s generate a sample employment contract. Create a file called Generate and preview the contract:
test-employee.json:test-employee.json
Generate Bulk Contracts
To generate multiple contracts at once, use the batch endpoint with an array of employees:Download all contracts as a ZIP:
bulk-employees.json
The ZIP file will contain organized folders for each contract type with all associated documents (contract, data processing agreement, and annexes).
Understanding Contract Types
Kontrak Backend supports three contract types, each with specific requirements:- PLANILLA (Standard)
- PART TIME
- SUBSIDIO (Substitution)
Standard full-time employment contracts.Minimum Required Fields:
Validation Rules
The API validates all employee data using Zod schemas. Common validation rules:| Field | Validation |
|---|---|
dni | Exactly 8 numeric digits |
email | Valid email format |
name, lastNameFather, lastNameMother | 2-50 characters, letters only |
salary | Must be greater than 0 |
entryDate, endDate | Format: DD/MM/YYYY |
contractType | Must be: PLANILLA, PART TIME, or SUBSIDIO |
Common Issues and Solutions
Error: DNI debe tener exactamente 8 dígitos numéricos
Error: DNI debe tener exactamente 8 dígitos numéricos
Ensure the DNI field contains exactly 8 numeric characters with no spaces or special characters.
Error: Fecha debe estar en formato DD/MM/YYYY
Error: Fecha debe estar en formato DD/MM/YYYY
Date fields must use the exact format DD/MM/YYYY with leading zeros.
Puppeteer fails to launch on Linux
Puppeteer fails to launch on Linux
If you’re on Linux and Puppeteer fails, install required dependencies:
Maximum 50 employees per batch error
Maximum 50 employees per batch error
The batch endpoint limits processing to 50 employees at a time for performance reasons.Split your data into smaller batches:
Next Steps
Full Installation Guide
Detailed setup for production environments
API Reference
Complete API endpoint documentation
Configuration
Advanced configuration options
Need Help?
If you encounter any issues:- Check the server logs for detailed error messages
- Verify your employee data against the validation schemas
- Review the Installation Guide for system requirements
- Consult the API Reference for endpoint specifications