Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sheeplettuce/Monitor/llms.txt

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

Upload a file as evidence for an insurance claim expediente. The file is stored on the server’s local filesystem inside a folder named after the siniestro number and organised by type. A new evidencia database record is created with the file’s metadata and a reference to the stored path.

Endpoint

POST /api/expedientes/:no_siniestro/evidencias
Authentication: Bearer token required. Only Administrador and Operador roles may upload evidence.

Path Parameters

no_siniestro
string
required
The siniestro number of the parent expediente (e.g. SIN-2024-001). The server verifies the expediente exists in the database before creating the record. Returns 404 if not found.

Query Parameters

tipo
string
Controls which subfolder the file lands in. When set to "documento", the file is saved under DOCUMENTOS REPARACION/. Omit this parameter (or use any other value) to store the file under the evidencias/ subfolder.
ValueDestination subfolder
"documento"DOCUMENTOS REPARACION/
(omitted)evidencias/

Request Body

Content-Type: multipart/form-data
archivo
file
required
The file to upload. Any MIME type is accepted. Maximum file size is 50 MB — requests exceeding this limit are rejected with 413.
The evidence base directory is resolved at startup as path.join(__dirname, '..', '..', 'evidencias') inside evidencias.routes.ts, placing it two levels above the compiled routes file (i.e. <project-root>/evidencias/). This path is hardcoded in the routes file and is not controlled by the EVIDENCIAS_DIR environment variable — that variable is only used by the health and status-check utilities for reporting purposes. Ensure <project-root>/evidencias/ exists and is writable by the Node.js process before uploading files.

Example Requests

# Upload a damage photo (stored in evidencias/ subfolder)
curl -X POST http://localhost:3000/api/expedientes/SIN-2024-001/evidencias \
  -H "Authorization: Bearer $TOKEN" \
  -F "archivo=@/path/to/damage-photo.jpg"
# Upload a repair document (stored in DOCUMENTOS REPARACION/ subfolder)
curl -X POST "http://localhost:3000/api/expedientes/SIN-2024-001/evidencias?tipo=documento" \
  -H "Authorization: Bearer $TOKEN" \
  -F "archivo=@/path/to/poliza.pdf"

File Storage Layout

Files are organised under the evidencias/ base directory as follows:
evidencias/
└── SIN-2024-001/
    ├── evidencias/                ← photos (default, ?tipo omitted)
    │   └── 1713900000000_damage-photo.jpg
    └── DOCUMENTOS REPARACION/     ← repair documents (?tipo=documento)
        └── 1713800000000_poliza.pdf
Filenames are saved as <unix_timestamp_ms>_<sanitized_original_name> — spaces in the original filename are replaced with underscores (file.originalname.replace(/\s+/g, '_')). This scheme prevents collisions when the same filename is uploaded multiple times.
The destination subfolder is created automatically with fs.mkdirSync({ recursive: true }) if it does not already exist, so no manual directory setup is needed beyond ensuring the base path is writable.

Response

201 — Created

Returns the newly created evidencia database record.
id
integer
Auto-incremented primary key of the new evidencia record.
no_siniestro
string
Siniestro number of the parent expediente, echoed from the path parameter.
tipo
string | null
MIME type of the uploaded file as reported by multer (e.g. image/jpeg, application/pdf).
nombre_archivo
string | null
Original filename provided by the client before server-side renaming.
ruta
string | null
Absolute filesystem path of the saved file as returned by multer after writing to disk. Use this path to serve or reference the file later.
fecha_carga
string | null
ISO 8601 timestamp set automatically by the database at insert time.
ubicacion_almacenamiento
string
Always "Local" for files uploaded through this endpoint.
subido_por
integer | null
ID of the authenticated usuario who performed the upload. Sourced from the JWT payload.

Example Response Body

{
  "id": 43,
  "no_siniestro": "SIN-2024-001",
  "tipo": "image/jpeg",
  "nombre_archivo": "damage-photo.jpg",
  "ruta": "/srv/app/evidencias/SIN-2024-001/evidencias/1713900000000_damage-photo.jpg",
  "fecha_carga": "2024-04-23T18:25:43.511Z",
  "ubicacion_almacenamiento": "Local",
  "subido_por": 7
}

Error Responses

StatusMeaning
400No file was included in the request body, or no_siniestro is not a valid string.
401Missing or invalid Bearer token.
403Authenticated user does not have the Administrador or Operador role.
404No expediente with the given no_siniestro exists in the database.
413Uploaded file exceeds the 50 MB size limit.
500Internal server error while saving the record — check server logs.
// 400 — no file
{ "error": "No se recibió ningún archivo" }

// 400 — bad siniestro
{ "error": "Número de siniestro inválido" }

// 404 — expediente not found
{ "error": "Expediente no encontrado" }

// 500
{ "error": "Error interno al registrar evidencia" }

Build docs developers (and LLMs) love