Create Document
Create a new document with optional file upload.Request Parameters
Unique document code (e.g., “FO-FMV-002”). Must be unique across the system.
Document title or description.
Document category (e.g., “Formato”, “Procedimiento”). Defaults to null.
Responsible area or department (e.g., “Farmacovigilancia”).
Initial version number. Defaults to “1.0”.
Document validity status (“true” or “false”). Defaults to “true”.
Document file to upload. Supported formats: .docx, .pdf, .txt
Response
Unique document identifier
Document code
Document title
Current version
Download URL for the document
Name of the uploaded file
Example Response
List Documents
Retrieve a paginated list of documents with optional filtering.Query Parameters
Search text for codigo, titulo, or categoria (case-insensitive partial match).
Filter by validity status. Omit to return all documents.
Filter by area (case-insensitive partial match).
Response
Update Document
Update document metadata and optionally upload a new file for the current version.Path Parameters
Document ID to update
Request Parameters
All parameters are optional. Only provided fields will be updated.New document code (must be unique)
Updated title
Updated category
Updated area
Updated version number
Validity status (“true” or “false”)
New file to replace the current version’s file
Create New Version
Create a new version of an existing document with a file upload.Path Parameters
Document ID to create a new version for
Request Parameters
Version number (e.g., “2.0”, “1.1”). Must be unique for this document.
Document file for the new version
Response
Returns the updated document with the new version set as current.Download Document
Download the current version of a document.Path Parameters
Document ID to download
Query Parameters
Download behavior: “attachment” (download) or “inline” (preview in browser)
Response
Returns the file binary content with appropriate Content-Type and Content-Disposition headers.Preview Document (PDF)
Generate and preview a PDF version of a DOCX document.Path Parameters
Document ID to preview
Query Parameters
Display behavior: “inline” (view in browser) or “attachment” (download)
Conversion Methods
The system attempts PDF conversion using:- LibreOffice (preferred, cross-platform)
- docx2pdf (Windows with MS Word)
Toggle Document Validity
Toggle or set a document’s validity status.Path Parameters
Document ID to toggle
Query Parameters
Explicit validity state. Omit to toggle the current state.
Generate from Template
Generate a document from a predefined template with dynamic data.Request Body
Template code to use (e.g., “FO-FMV-002”, “FO-FMV-008”, “PD-FMV-010”)
Version number for the generated document
Key-value pairs for template field substitution. Required fields depend on the template.
Template Processing
- If a DOCX template exists at
app/templates/docs/{codigo}.docx, it’s rendered using docxtpl - Otherwise, generates PDF/TXT using the template body with placeholder substitution
- Automatically calculates
vigenciadate (+3 years) ifemisionis provided
Available Templates
- FO-FMV-002: Notificación de Sospecha de Reacción Adversa
- FO-FMV-008: Registro de Seguimiento de Paciente
- PD-FMV-010: Procedimiento de Gestión de Reacciones Adversas
Use
GET /api/v1/documentos/plantillas to retrieve the full list of available templates and their required fields.Version Management
List Document Versions
Get all versions of a document.GET /api/v1/documentos/{doc_id}/versions
Switch to Specific Version
Set a specific version as the current active version.POST /api/v1/documentos/{doc_id}/use-version
Download Specific Version
Download a specific version instead of the current one.GET /api/v1/documentos/{doc_id}/versions/{version}/download
Error Codes
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid parameters, duplicate code, or version already exists |
| 404 | Not Found - Document, version, or file not found |
| 500 | Internal Server Error - PDF conversion failed or file system error |
Best Practices
- Unique Codes: Always use unique document codes (e.g., FO-FMV-XXX)
- Version Numbering: Follow semantic versioning (1.0, 1.1, 2.0)
- File Formats: Prefer DOCX for documents requiring template processing
- Preview Before Export: Use the preview endpoint to verify documents before final export
- Version Control: Create new versions instead of overwriting existing files
Next: Digital Signatures
Learn how to add digital signatures to documents