ADocumentation 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.
GeneratedDocument is the result of merging a DocumentTemplate with the live data of a specific employee. At generation time the service resolves all {{VARIABLE}} placeholders and writes the output into contenidoFinal — an immutable HTML snapshot that never changes even if the employee’s profile or the template is later updated. Once created, a document can be converted to PDF by calling the dedicated render endpoint, which saves the binary to Cloudflare R2 storage, updates the pdfUrl field, and atomically creates an ExpedienteDoc record so the file appears in the employee’s digital file.
All endpoints require a valid JWT.
Generate document
GeneratedDocument record by resolving template variables against the specified employee’s data and the tenant profile. The response contains the rendered contenidoFinal but no PDF yet — call POST /generated-documents/:id/generate-pdf to produce the binary.
UUID of the employee whose data populates the template variables.
UUID of the active
DocumentTemplate to render. Returns 400 Bad Request if the template is inactive.Display name for this generated document (e.g.
"Contrato Laura Gómez — Marzo 2024").Identifier of the newly created
GeneratedDocument record.Display name as provided in the request.
Template type inherited from the source template:
CONTRACT, CERTIFICATION, LETTER, or MEMO.Immutable HTML snapshot with all placeholders already replaced. This field is never recomputed after creation.
Always
null at this stage. Populated after calling POST /:id/generate-pdf.Employee associated with this document.
Source template identifier.
Creation timestamp.
List generated documents
Page number, minimum
1. Defaults to 1.Records per page, minimum
1. Defaults to 10.Case-insensitive search across
nombre and contenidoFinal.Restrict results to documents generated for a specific employee.
Filter by document type. One of
CONTRACT, CERTIFICATION, LETTER, MEMO.Page of document records. Each record includes an embedded
employee object (id, primerNombre, segundoNombre, primerApellido, segundoApellido, cedula, cargo, sedeRef) and a template object (id, nombre, tipo).Total matching records.
Current page.
Page size.
Total pages.
Get generated document
Generated document identifier.
Document identifier.
Display name.
Document type.
Immutable rendered HTML.
R2 URL path of the PDF file, or
null if not yet generated.Contract linked to this document, if generated through the contract pipeline.
Embedded employee snapshot:
id, primerNombre, segundoNombre, primerApellido, segundoApellido, cedula, cargo, tipoDocumento, sedeRef.Embedded template snapshot:
id, nombre, tipo.Creation timestamp.
Render PDF
contenidoFinal HTML into a styled PDF. The rendering pipeline wraps the content in a full HTML page with tenant branding (logo, company name) and employee identification in the header. The resulting binary is saved to Cloudflare R2 and linked back on the document record.
Generated document identifier.
Document identifier.
Storage path of the generated PDF (e.g.
/uploads/pdfs/{tenantId}-{id}.pdf).Document display name.
PDF generation and
ExpedienteDoc record creation are committed inside a single database transaction. Either both succeed or neither does — you will never end up with an orphaned PDF entry or a missing expediente record.PDF generation flow
- The service fetches the
GeneratedDocumentand its parentTenant. - A full HTML document is assembled, with the tenant logo and legal name in the header and the employee’s full name and document number as a subtitle.
- The HTML is rendered to a PDF binary via
PdfRenderService. - The binary is stored in R2 under the key
pdfs/{tenantId}-{id}.pdf. - Inside a single Prisma transaction:
pdfUrlis written to theGeneratedDocumentrow and anExpedienteDocrecord is created, inheriting thecontratoIdif present. - An audit event
PDF_GENERATEis emitted asynchronously.
Download PDF
404 Not Found if the PDF has not yet been generated or the file cannot be located on disk.
Generated document identifier.
Content-Type: application/pdf and Content-Disposition: inline; filename="{nombre}.pdf".
Delete generated document
GeneratedDocument record. Associated ExpedienteDoc records that reference this document via generatedDocumentId are not automatically removed — delete them separately through DELETE /expediente-docs/:id if needed.
Generated document identifier.
Identifier of the deleted record.