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.

The Document Templates API manages reusable HTML templates that drive the document-generation pipeline. Each template stores a contenido string containing HTML markup with {{VARIABLE}} placeholders. When a document is generated from a template, the service resolves each placeholder against the employee’s current data and the tenant’s profile, producing an immutable contenidoFinal snapshot. Templates are soft-deleted and support an activo toggle so they can be suspended without losing history. Four built-in template types are supported: CONTRACT, CERTIFICATION, LETTER, and MEMO. All endpoints require a valid JWT. The base controller applies ADMIN or OPERADOR role gates, with write operations additionally requiring ADMIN.
Authorization: Bearer {accessToken}

List templates

GET /document-templates
Roles: ADMIN, OPERADOR
page
number
Page number, minimum 1. Defaults to 1.
limit
number
Records per page, minimum 1. Defaults to 10.
Case-insensitive search against nombre and descripcion.
tipo
string
Filter by template type. One of CONTRACT, CERTIFICATION, LETTER, MEMO.
data
DocumentTemplate[]
Page of template objects.
meta.total
number
Total matching templates.
meta.page
number
Current page.
meta.limit
number
Page size.
meta.totalPages
number
Total pages.
curl "https://api.oficinaclear.com/document-templates?tipo=CONTRACT&page=1&limit=20" \
  -H "Authorization: Bearer $TOKEN"

Create template

POST /document-templates
Roles: ADMIN
nombre
string
required
Human-readable template name (e.g. "Contrato término fijo 2024").
tipo
string
required
Template category. One of CONTRACT, CERTIFICATION, LETTER, MEMO.
contenido
string
required
HTML body of the template. Use {{VARIABLE}} syntax to insert dynamic values. See the Variable reference below.
descripcion
string
Short description visible in the template list.
id
string (UUID)
Newly created template identifier.
activo
boolean
Always true on creation.
createdAt
string (ISO 8601)
Creation timestamp.
curl -X POST https://api.oficinaclear.com/document-templates \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Contrato término fijo 2024",
    "tipo": "CONTRACT",
    "descripcion": "Plantilla estándar para contratos a término fijo",
    "contenido": "<h2>CONTRATO INDIVIDUAL DE TRABAJO</h2><p>Entre <strong>{{EMPRESA}}</strong>, NIT {{NIT}}, y <strong>{{NOMBRE_COMPLETO}}</strong>, identificado(a) con {{DOCUMENTO}}, se celebra el presente contrato.</p>"
  }'

Get template

GET /document-templates/:id
Roles: ADMIN, OPERADOR
id
string (UUID)
required
Template identifier.
id
string (UUID)
Template identifier.
nombre
string
Template name.
descripcion
string | null
Optional description.
tipo
string
Template type enum value.
contenido
string
Full HTML body with {{VARIABLE}} placeholders.
activo
boolean
Whether the template is available for document generation.
createdAt
string (ISO 8601)
Creation timestamp.
updatedAt
string (ISO 8601)
Last-updated timestamp.

Update template

PATCH /document-templates/:id
Roles: ADMIN
All body fields are optional.
id
string (UUID)
required
Template identifier.
nombre
string
New template name.
descripcion
string
New description.
tipo
string
New template type. One of CONTRACT, CERTIFICATION, LETTER, MEMO.
contenido
string
Replacement HTML body. Does not affect already-generated documents.
activo
boolean
Set to false to suspend the template without deleting it.
curl -X PATCH https://api.oficinaclear.com/document-templates/t1e2m3p-0000-0000-0000-000000000003 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"activo": false}'

Toggle template active state

PATCH /document-templates/:id/toggle
Roles: ADMIN
Flips the activo boolean of the template without requiring a body. Equivalent to PATCH /:id with { "activo": !current } but more convenient for UI toggle actions.
id
string (UUID)
required
Template identifier.
activo
boolean
New value of the activo flag after the toggle.

Delete template

DELETE /document-templates/:id
Roles: ADMIN
Soft-deletes the template by setting deletedAt and activo: false. The template is excluded from all list queries and cannot be selected for new document generation, but GeneratedDocument records that reference it remain intact.
id
string (UUID)
required
Template identifier.
id
string (UUID)
Identifier of the deleted template.
deletedAt
string (ISO 8601)
Timestamp of the soft delete.

Seed default templates

POST /document-templates/seed
Roles: ADMIN
Creates the four platform-defined default templates for the current tenant if they do not already exist. Safe to call multiple times — existing templates are not overwritten. This endpoint is typically called once during tenant onboarding.
Seeded templateType
Contrato laboral estándarCONTRACT
Certificación laboralCERTIFICATION
Carta formalLETTER
Memorando internoMEMO
[*]
DocumentTemplate[]
Array of the created template records. Templates that already existed for the tenant are excluded.
curl -X POST https://api.oficinaclear.com/document-templates/seed \
  -H "Authorization: Bearer $TOKEN"

Duplicate template

POST /document-templates/:id/duplicate
Roles: ADMIN
Creates a copy of an existing template. The duplicate is created as activo: true and its contenido, descripcion, and tipo are copied verbatim. The original is left unchanged.
id
string (UUID)
required
Identifier of the source template to duplicate.
nombre
string
Custom name for the duplicate. Defaults to "{source nombre} (copia)".
id
string (UUID)
Identifier of the newly created duplicate template.
nombre
string
Name of the duplicate.
curl -X POST https://api.oficinaclear.com/document-templates/t1e2m3p-0000-0000-0000-000000000003/duplicate \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"nombre": "Contrato término fijo — versión bilingüe"}'

Template variable reference

Place any of the following tokens inside your contenido HTML using double-brace syntax. The generation service replaces each token with the resolved value at the time POST /generated-documents/generate is called.
VariableResolved value
{{NOMBRE_COMPLETO}}Employee’s full name (primerNombre segundoNombre primerApellido segundoApellido)
{{DOCUMENTO}}Document type and number, e.g. "CC 1012345678"
{{CARGO}}Job title from the employee record
{{SALARIO}}Monthly salary formatted as Colombian peso, e.g. "$5.800.000"
{{TIPO_CONTRATO}}Human-readable contract type, e.g. "Término Indefinido"
{{FECHA_INGRESO}}Start date in long Spanish locale, e.g. "1 de marzo de 2024"
{{SEDE}}Name of the assigned branch office (sedeRef.nombre), or empty string
{{EMPRESA}}Tenant’s razonSocial or nombre
{{NIT}}Tenant’s NIT
{{REPRESENTANTE_LEGAL}}Tenant’s legal representative name, or "No definido"
{{LOGO_EMPRESA}}Inline <img> tag for the tenant logo, or empty string if no logo
{{FIRMA_REPRESENTANTE}}Inline <img> tag for the representative signature, or empty string
Unknown variables are left unreplaced in contenidoFinal. Always verify your template renders correctly by generating a test document before using it in production.

Build docs developers (and LLMs) love