Skip to main content
POST
/
api
/
contracts
/
download-zip
Download Contracts ZIP
curl --request POST \
  --url https://api.example.com/api/contracts/download-zip \
  --header 'Content-Type: application/json' \
  --data '
{
  "employees": [
    {
      "name": "<string>",
      "lastNameFather": "<string>",
      "lastNameMother": "<string>",
      "birthDate": "<string>",
      "sex": "<string>",
      "dni": "<string>",
      "email": "<string>",
      "address": "<string>",
      "province": "<string>",
      "district": "<string>",
      "department": "<string>",
      "salary": 123,
      "salaryInWords": "<string>",
      "position": "<string>",
      "entryDate": "<string>",
      "endDate": "<string>",
      "subDivisionOrParking": "<string>",
      "contractType": "<string>",
      "replacementFor": "<string>",
      "reasonForSubstitution": "<string>",
      "timeForCompany": "<string>",
      "workingCondition": "<string>",
      "probationaryPeriod": "<string>"
    }
  ]
}
'
{
  "Content-Type": "<string>",
  "Content-Disposition": "<string>",
  "Body": {}
}

Overview

This endpoint generates contracts for multiple employees and returns them as a ZIP file. For each employee, the ZIP contains:
  • The employment contract PDF
  • A personal data processing agreement PDF
  • Contract annexes PDF
Files are organized in folders by contract type (e.g., planilla/, parttime/, subsidio/).

Request

Body Parameters

The request body must be an array of employee objects (minimum 1, maximum 50 employees per batch).
employees
array
required
Array of employee objects to generate contracts for

Response

Success Response

Content-Type
string
application/zip
Content-Disposition
string
attachment; filename="contratos-DD-MM-YYYY.zip"The filename includes the current date when the ZIP was generated.
Body
binary
ZIP file containing all generated contracts

ZIP File Structure

The ZIP file is organized as follows:
contratos-05-03-2026.zip
├── planilla/
│   ├── {dni}-{position}.pdf              (Main contract)
│   ├── Tratamiento de datos/
│   │   └── {dni}.pdf                     (Data processing agreement)
│   └── Anexos/
│       └── {dni}.pdf                     (Contract annexes)
├── parttime/
│   └── (same structure)
└── subsidio/
    └── (same structure)

Error Responses

400 - Validation Error
{
  "success": false,
  "message": "La solicitud no se pudo procesar",
  "errors": [
    {
      "field": "body.0.dni",
      "message": "DNI debe tener exactamente 8 dígitos numéricos."
    },
    {
      "field": "body.1.contractType",
      "message": "El tipo de contrato debe ser: Planilla, Subsidio, Part Time"
    }
  ]
}
400 - Empty Array
{
  "success": false,
  "message": "La solicitud no se pudo procesar",
  "errors": [
    {
      "field": "body",
      "message": "Debes seleccionar al menos un empleado para generar el ZIP."
    }
  ]
}
400 - Too Many Employees
{
  "success": false,
  "message": "La solicitud no se pudo procesar",
  "errors": [
    {
      "field": "body",
      "message": "Máximo 80 empleados por lote"
    }
  ]
}

Examples

Basic Example (Planilla Contract)

curl -X POST https://api.example.com/api/contracts/download-zip \
  -H "Content-Type: application/json" \
  -d '[
    {
      "name": "Juan",
      "lastNameFather": "García",
      "lastNameMother": "López",
      "birthDate": "15/06/1990",
      "sex": "Masculino",
      "dni": "12345678",
      "email": "[email protected]",
      "address": "Av. Principal 123",
      "province": "Lima",
      "district": "Miraflores",
      "department": "Lima",
      "salary": 3500,
      "salaryInWords": "tres mil quinientos soles",
      "position": "Desarrollador",
      "entryDate": "01/03/2026",
      "endDate": "31/12/2026",
      "subDivisionOrParking": "Tecnología",
      "contractType": "Planilla"
    }
  ]' \
  --output contratos.zip

Multiple Employees with Different Contract Types

curl -X POST https://api.example.com/api/contracts/download-zip \
  -H "Content-Type: application/json" \
  -d '[
    {
      "name": "María",
      "lastNameFather": "Pérez",
      "lastNameMother": "Silva",
      "birthDate": "20/03/1992",
      "sex": "Femenino",
      "dni": "87654321",
      "email": "[email protected]",
      "address": "Calle Los Olivos 456",
      "province": "Lima",
      "district": "San Isidro",
      "department": "Lima",
      "salary": 2500,
      "salaryInWords": "dos mil quinientos soles",
      "position": "Asistente",
      "entryDate": "15/03/2026",
      "endDate": "15/09/2026",
      "subDivisionOrParking": "Administración",
      "contractType": "Part Time"
    },
    {
      "name": "Carlos",
      "lastNameFather": "Rodríguez",
      "lastNameMother": "Torres",
      "birthDate": "10/08/1988",
      "sex": "Masculino",
      "dni": "45678912",
      "email": "[email protected]",
      "address": "Jr. Las Flores 789",
      "province": "Lima",
      "district": "Surco",
      "department": "Lima",
      "salary": 4000,
      "salaryInWords": "cuatro mil soles",
      "position": "Analista Senior",
      "entryDate": "01/04/2026",
      "endDate": "30/06/2026",
      "subDivisionOrParking": "Finanzas",
      "contractType": "Subsidio",
      "replacementFor": "Ana Martínez",
      "reasonForSubstitution": "Licencia por maternidad",
      "timeForCompany": "3 meses",
      "workingCondition": "Tiempo completo",
      "probationaryPeriod": "30 días"
    }
  ]' \
  --output contratos.zip

Implementation Notes

  • The ZIP file is streamed directly to the response using Archiver with maximum compression (level 9)
  • Each employee’s documents are generated in parallel using Puppeteer
  • If an individual employee’s contract generation fails, the error is logged but the process continues for other employees
  • The filename uses the current date in DD-MM-YYYY format
  • Folder names in the ZIP are lowercase and spaces are removed from contract types
  • File paths follow the pattern: {contractType}/{filename} for contracts and {contractType}/Tratamiento de datos/{dni}.pdf for data processing documents
  • Preview Contract - Preview a single employee contract before generating a batch

Build docs developers (and LLMs) love