Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Glemynart/SaaS/llms.txt

Use this file to discover all available pages before exploring further.

La Oficina Nítida’s document engine lets each organization maintain its own library of reusable templates. A template is a plain-text document with {{VARIABLE}} placeholders that are replaced at generation time with real employee and tenant data. The result is a pixel-perfect, tenant-branded PDF that lands directly in the employee’s digital file. Templates are per-tenant — every organization manages its own library independently.

Template Types

The tipo field classifies a template according to its intended use. This classification controls how generated PDFs are categorized in the employee’s expediente.
ValuePurpose
CONTRACTEmployment or services contract documents
CERTIFICATIONEmployment certificates and letters
LETTERGeneral correspondence and formal notices
MEMOInternal memoranda
The Prisma schema also defines a Plantilla model with a separate PlantillaTipo enum (CONTRATO, PREAVISO, TERMINACION, CERTIFICADO, OTRO). The DocumentTemplate model described on this page is the current active model for the document generation engine. New development should use DocumentTemplate exclusively.

How Templates Work

A template’s body is stored in the contenido field as a text string containing {{VARIABLE}} placeholders. At generation time the engine scans the content, resolves each placeholder from the employee and tenant data, and writes the final document.

Available variables

PlaceholderSource
{{NOMBRE_COMPLETO}}Full name built via formatNombreCompleto() from all four name fields
{{DOCUMENTO}}Combined document type and number, e.g. CC 1020304050
{{CARGO}}employee.cargo — the employee’s current job title
{{SALARIO}}employee.salario — formatted as Colombian pesos (e.g. $1.800.000)
{{TIPO_CONTRATO}}employee.tipoContrato — human-readable label (e.g. Término Fijo)
{{FECHA_INGRESO}}employee.fechaIngreso — formatted in long es-CO locale
{{SEDE}}employee.sedeRef?.nombre — resolved from the formal Sede relationship
{{EMPRESA}}tenant.razonSocial or tenant.nombre
{{NIT}}tenant.nit
{{REPRESENTANTE_LEGAL}}tenant.representanteLegal
{{LOGO_EMPRESA}}Inline <img> tag for the tenant logo stored in R2
{{FIRMA_REPRESENTANTE}}Inline <img> tag for the representative’s signature stored in R2
Variable values are read from the live employee and tenant records at the moment of generation. The contenidoFinal stored on the resulting GeneratedDocument record is an immutable snapshot of the rendered content — even if the employee’s cargo or salary changes later, the generated document preserves the values at generation time.

Example template body

CONTRATO DE TRABAJO A TÉRMINO FIJO

Conste por el presente documento que entre {{NOMBRE_COMPLETO}},
identificado(a) con {{DOCUMENTO}}, y {{EMPRESA}} (NIT {{NIT}}),
representada por {{REPRESENTANTE_LEGAL}}, se celebra el siguiente
contrato de trabajo:

CARGO: {{CARGO}}
SALARIO MENSUAL: {{SALARIO}}
TIPO DE CONTRATO: {{TIPO_CONTRATO}}
FECHA DE INICIO: {{FECHA_INGRESO}}
SEDE: {{SEDE}}

Template Management Endpoints

All endpoints require ADMIN or OPERADOR role, with write operations (POST, PATCH, DELETE) restricted to ADMIN.

Seed default templates

POST /document-templates/seed
Populates the tenant’s library with a set of platform-default templates. Useful during onboarding. Requires ADMIN role.

Create a template

POST /document-templates
Content-Type: application/json

{
  "nombre": "Contrato Término Fijo 2024",
  "descripcion": "Plantilla estándar para contratos a término fijo",
  "tipo": "CONTRACT",
  "contenido": "CONTRATO DE TRABAJO...\n{{NOMBRE_COMPLETO}}..."
}
CreateDocumentTemplateDto fields:
FieldRequiredDescription
nombreDisplay name for the template
descripcionOptional description
tipoCONTRACT, CERTIFICATION, LETTER, or MEMO
contenidoTemplate body with {{VARIABLE}} placeholders

List templates

GET /document-templates
Returns all active templates for the authenticated tenant. Supports filtering via DocumentTemplateQueryDto query parameters.

Get a single template

GET /document-templates/:id

Update a template

PATCH /document-templates/:id
Content-Type: application/json

{
  "nombre": "Contrato Término Fijo 2025",
  "contenido": "..."
}

Delete a template

DELETE /document-templates/:id
Soft-deletes the template (deletedAt is set). Existing GeneratedDocument records that reference this template are not affected.

Toggle active status

PATCH /document-templates/:id/toggle
Switches the template’s activo flag between true and false. Inactive templates do not appear in the default list view.

Duplicate a template

POST /document-templates/:id/duplicate
Content-Type: application/json

{
  "nombre": "Contrato Término Fijo 2025 (copia)"
}
Creates a new template with the same tipo and contenido as the source, under the specified new name. Useful for creating year-over-year variants without starting from scratch.

PDF Generation Workflow

Individual document generation

Generate a PDF for a specific contract using a chosen template:
POST /contracts/:id/generate-document
Content-Type: application/json

{
  "templateId": "t9u8v7w6-..."
}
Or generate a document directly from the generated-documents module (not tied to a specific contract):
POST /generated-documents/generate
Content-Type: application/json

{
  "employeeId": "e1f2a3b4-...",
  "templateId": "t9u8v7w6-...",
  "nombre": "Certificado Laboral - Enero 2025"
}
After generation, trigger the PDF conversion:
POST /generated-documents/:id/generate-pdf
Download the resulting file:
GET /generated-documents/:id/pdf

Batch generation (lotes)

For generating contracts across an entire branch or employee group simultaneously, use the LoteContrato workflow. A batch job is enqueued, processed by BullMQ, and the resulting PDFs are packaged into a ZIP archive available for download when the lote reaches COMPLETADO status.
PDF generation requires the Gotenberg/LibreOffice conversion service to be running and accessible to the API. If the service is unavailable, the generate-pdf step will fail. Verify the service is healthy before running batch generation jobs in production.
Templates are per-tenant — each organization has its own isolated library. A template created by one tenant is never visible to another. When onboarding a new tenant, use POST /document-templates/seed to provision the default set before any contract generation begins.

Build docs developers (and LLMs) love