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.

An expediente is the central record in Monitor API, representing a vehicle’s complete insurance claim from the moment it arrives at the shop to its final delivery. Every piece of data — vehicle details, client information, assigned staff, documents received, evidence files, and damage surveys — is tied to a single expediente identified by its unique no_siniestro (claim/accident number).

Lifecycle stages

Each expediente moves through four ordered states that reflect the vehicle’s physical progress through the repair process:
StateMeaning
IngresoVehicle has arrived and the claim has been opened. This is the default state on creation.
RestauracionActive repair and restoration work is underway.
Pendiente_de_salidaRepairs are complete; the vehicle is awaiting final inspection, payment, or paperwork.
SalidaThe vehicle has been delivered to the client and the claim is closed.
The typical progression is:
Ingreso → Restauracion → Pendiente_de_salida → Salida
When an expediente is first created, Monitor API automatically writes the opening entry to the historial_estado table recording estado_anterior as null, estado_nuevo as Ingreso, a fecha_cambio timestamp, and the cambiado_por user ID of the creator. This gives you a full, tamper-evident audit trail for every claim from the moment it is opened.
The estado field cannot be changed via PUT /api/expedientes/:no_siniestro. The service layer strips any estado value submitted through that endpoint. Status transitions must be managed through your own workflow logic (for example, direct database updates or a dedicated state-management endpoint in your environment). Only the initial Ingreso state is set automatically on creation.
Always include id_aseguradora when creating an expediente so the record is properly linked to the insurer. You can retrieve a list of available insurers from GET /api/expedientes/aseguradoras before creating the claim.

Creating an expediente

Only users with the Administrador or Operador role may create expedientes. The only required field is no_siniestro — the official claim or accident reference number. It must be unique across the database; attempting to create a duplicate returns 409 Conflict.
curl -X POST http://localhost:3000/api/expedientes \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "no_siniestro": "SIN-2024-001",
    "marca": "Toyota",
    "modelo": "Corolla",
    "tipo": "Sedan",
    "color": "Blanco",
    "placas": "ABC-123",
    "nombre_cliente": "Juan García",
    "telefono_cliente": "555-0100",
    "id_aseguradora": 1
  }'
On success, the API returns 201 Created with the full expediente object. The estado is automatically set to Ingreso and the first historial_estado entry is written in the same operation.
Date fields (fecha_ingreso, fecha_valuacion, fecha_autorizacion, fecha_pzas_completas, unidad_terminada) accept strings in YYYY-MM-DD format. The API normalises them to noon UTC internally to prevent timezone-related off-by-one day errors.

Fetching expedientes

List all

GET /api/expedientesReturns a summary array of all expedientes, ordered by fecha_ingreso descending. Each object includes no_siniestro, estado, vehicle fields, nombre_cliente, and the linked aseguradora.

Get one

GET /api/expedientes/:no_siniestroReturns the full expediente record including nested aseguradora, historial_estado (most-recent-first), and evidencia arrays.

List insurers

GET /api/expedientes/aseguradorasReturns [{ id, nombre }] for all registered insurance companies. Use this to populate dropdowns before creating a new claim.
All three endpoints require a valid Authorization: Bearer <token> header. The Técnico role has read-only access to these endpoints.

Updating an expediente

PUT /api/expedientes/:no_siniestro performs a partial update — only include the fields you want to change. Requires the Administrador or Operador role.
# Update the assigned technician and add an observation
curl -X PUT http://localhost:3000/api/expedientes/SIN-2024-001 \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "tecnico": "Carlos Mendoza", "observaciones": "Daño adicional en panel trasero" }'
The estado field is silently ignored by this endpoint — submitting it has no effect. Status is set to Ingreso at creation and is not modifiable through the standard update endpoint.
Returns the updated expediente object on success. Returns 404 if the siniestro does not exist.

Deleting an expediente

DELETE /api/expedientes/:no_siniestro permanently removes the expediente and all associated records in a single transaction: checklists, checklist items, levantamientos, levantamiento concepts, evidence records, and status history entries. This action requires the Administrador role.
curl -X DELETE http://localhost:3000/api/expedientes/SIN-2024-001 \
  -H "Authorization: Bearer $TOKEN"
Response:
{ "ok": true, "no_siniestro": "SIN-2024-001" }
Returns 404 if the expediente is not found.

Document checklist

Each expediente tracks whether the required paper documents have been received using a set of boolean fields. Set each field to true via PUT /api/expedientes/:no_siniestro as the corresponding document arrives at the shop:
FieldDocument
doc_orden_admisionAdmission order
doc_identificacionClient government-issued ID
doc_tarjeta_circulacionVehicle registration card
doc_caratula_polizaInsurance policy cover page
doc_carta_reparacionRepair authorisation letter from insurer
doc_comprobante_deducibleDeductible payment receipt
doc_finiquitoSettlement / final release document
doc_encuesta_servicioCustomer satisfaction survey
All fields default to null (not yet received). A value of true means the document is in hand; false means it was explicitly marked as absent.

Build docs developers (and LLMs) love