Skip to main content

Introduction

Maintenance sessions (sesiones_mantenimiento) track the actual work performed during maintenance activities. Each session records:
  • Which technician performed the work
  • When the work was done
  • How long it took
  • What was accomplished
  • Associated costs
Sessions provide granular tracking of maintenance execution and support accurate cost accounting.
API Endpoints Not Yet Implemented: RESTful endpoints for maintenance sessions are not available in the current version. This page documents the data model for reference. Session management is performed through the Eloquent ORM.

Session Model

Each session belongs to a parent maintenance record (mantenimiento) and captures:
id
integer
Unique session identifier
mantenimiento_id
integer
required
Foreign key to parent maintenance record
tecnico_id
integer
required
ID of the technician who performed this work
fecha
datetime
Date and time when work was performed
horas_trabajadas
float
Number of hours worked in this session
descripcion_trabajo
string
Description of work completed
observaciones
string
Additional observations or findings
costo_total
float
Total cost for this work session

List Sessions

Get all work sessions for a specific maintenance record.
GET /api/tecnica/mantenimientos/{mantenimiento_id}/sesiones

Path Parameters

mantenimiento_id
integer
required
Maintenance record ID

Query Parameters

tecnico_id
integer
Filter sessions by technician
fecha_desde
date
Filter sessions from this date
fecha_hasta
date
Filter sessions until this date
include
string
Include related data: tecnico

Response

{
  "data": [
    {
      "id": 1,
      "mantenimiento_id": 5,
      "tecnico_id": 3,
      "fecha": "2026-03-06T09:00:00Z",
      "horas_trabajadas": 4.5,
      "descripcion_trabajo": "Diagnóstico inicial y desmontaje del equipo",
      "observaciones": "Sistema de ventilación completamente obstruido",
      "costo_total": 1200.00,
      "created_at": "2026-03-06T09:00:00Z",
      "updated_at": "2026-03-06T14:30:00Z",
      "tecnico": {
        "id": 3,
        "name": "Ana Técnico",
        "email": "[email protected]"
      }
    },
    {
      "id": 2,
      "mantenimiento_id": 5,
      "tecnico_id": 3,
      "fecha": "2026-03-07T10:00:00Z",
      "horas_trabajadas": 3.0,
      "descripcion_trabajo": "Limpieza completa y reinstalación",
      "observaciones": "Sistema funcionando dentro de parámetros normales",
      "costo_total": 1300.00,
      "created_at": "2026-03-07T10:00:00Z",
      "updated_at": "2026-03-07T15:00:00Z"
    }
  ],
  "meta": {
    "total_sesiones": 2,
    "total_horas": 7.5,
    "total_costo": 2500.00
  }
}

Authorization

Requires tecnico, supervisor, or admin role

Get Single Session

Retrieve details of a specific work session.
GET /api/tecnica/sesiones/{id}

Path Parameters

id
integer
required
Session ID

Response

{
  "data": {
    "id": 1,
    "mantenimiento_id": 5,
    "tecnico_id": 3,
    "fecha": "2026-03-06T09:00:00Z",
    "horas_trabajadas": 4.5,
    "descripcion_trabajo": "Diagnóstico inicial y desmontaje del equipo",
    "observaciones": "Sistema de ventilación completamente obstruido",
    "costo_total": 1200.00,
    "created_at": "2026-03-06T09:00:00Z",
    "updated_at": "2026-03-06T14:30:00Z",
    "tecnico": {
      "id": 3,
      "name": "Ana Técnico",
      "email": "[email protected]"
    },
    "mantenimiento": {
      "id": 5,
      "tipo": "correctivo",
      "estado": "en_proceso",
      "activo": {
        "id": 8,
        "articulo": {
          "marca": "Dell",
          "modelo": "PowerEdge R740"
        }
      }
    }
  }
}

Create Session

Record a new work session for a maintenance activity.
POST /api/tecnica/mantenimientos/{mantenimiento_id}/sesiones

Path Parameters

mantenimiento_id
integer
required
Maintenance record ID

Request Body

tecnico_id
integer
required
ID of the technician performing the work
fecha
datetime
Date and time of work (defaults to current time)
horas_trabajadas
float
Number of hours worked
descripcion_trabajo
string
Description of work completed
observaciones
string
Additional observations or findings
costo_total
float
Total cost for this session

Example Request

curl -X POST "https://api.gima.example/api/tecnica/mantenimientos/5/sesiones" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "tecnico_id": 3,
    "fecha": "2026-03-06T09:00:00Z",
    "horas_trabajadas": 4.5,
    "descripcion_trabajo": "Diagnóstico inicial y desmontaje del equipo",
    "observaciones": "Sistema de ventilación completamente obstruido",
    "costo_total": 1200.00
  }'

Example Response

{
  "data": {
    "id": 1,
    "mantenimiento_id": 5,
    "tecnico_id": 3,
    "fecha": "2026-03-06T09:00:00Z",
    "horas_trabajadas": 4.5,
    "descripcion_trabajo": "Diagnóstico inicial y desmontaje del equipo",
    "observaciones": "Sistema de ventilación completamente obstruido",
    "costo_total": 1200.00,
    "created_at": "2026-03-06T09:00:00Z",
    "updated_at": "2026-03-06T09:00:00Z"
  },
  "message": "Session created successfully"
}

Authorization

Requires tecnico, supervisor, or admin role
Technicians can only create sessions assigned to themselves

Update Session

Update an existing work session.
PUT /api/tecnica/sesiones/{id}
PATCH /api/tecnica/sesiones/{id}

Path Parameters

id
integer
required
Session ID to update

Request Body

All fields are optional when updating:
fecha
datetime
Update work date/time
horas_trabajadas
float
Update hours worked
descripcion_trabajo
string
Update work description
observaciones
string
Update observations
costo_total
float
Update session cost

Example Request

curl -X PATCH "https://api.gima.example/api/tecnica/sesiones/1" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "horas_trabajadas": 5.0,
    "observaciones": "Trabajo tomó más tiempo del estimado debido a piezas adicionales"
  }'

Authorization

Requires supervisor or admin role, or tecnico role for own sessions

Delete Session

Remove a work session record.
DELETE /api/tecnica/sesiones/{id}

Path Parameters

id
integer
required
Session ID to delete

Response

{
  "message": "Session deleted successfully"
}

Authorization

Requires supervisor or admin role
Deleting a session will recalculate the parent maintenance’s total cost

Get Technician Sessions

Retrieve all sessions for a specific technician.
GET /api/tecnica/tecnicos/{tecnico_id}/sesiones

Path Parameters

tecnico_id
integer
required
Technician user ID

Query Parameters

fecha_desde
date
Filter sessions from this date
fecha_hasta
date
Filter sessions until this date
mantenimiento_id
integer
Filter by specific maintenance

Response

{
  "data": [
    {
      "id": 1,
      "mantenimiento_id": 5,
      "fecha": "2026-03-06T09:00:00Z",
      "horas_trabajadas": 4.5,
      "descripcion_trabajo": "Diagnóstico inicial",
      "costo_total": 1200.00
    }
  ],
  "meta": {
    "tecnico_id": 3,
    "tecnico_name": "Ana Técnico",
    "total_sesiones": 1,
    "total_horas": 4.5,
    "total_costo": 1200.00,
    "periodo": {
      "desde": "2026-03-01",
      "hasta": "2026-03-31"
    }
  }
}

Authorization

Technicians can view their own sessions. Supervisors and admins can view all sessions.

Session Statistics

Get aggregated statistics for maintenance sessions.
GET /api/tecnica/sesiones/estadisticas

Query Parameters

fecha_desde
date
Start date for statistics
fecha_hasta
date
End date for statistics
tecnico_id
integer
Filter by technician
mantenimiento_tipo
string
Filter by maintenance type: preventivo, correctivo, predictivo

Response

{
  "data": {
    "total_sesiones": 150,
    "total_horas": 687.5,
    "total_costo": 185000.00,
    "promedio_horas_por_sesion": 4.58,
    "promedio_costo_por_sesion": 1233.33,
    "por_tecnico": [
      {
        "tecnico_id": 3,
        "tecnico_name": "Ana Técnico",
        "sesiones": 45,
        "horas": 210.5,
        "costo": 58000.00
      }
    ],
    "por_tipo_mantenimiento": {
      "preventivo": {
        "sesiones": 80,
        "horas": 350.0,
        "costo": 95000.00
      },
      "correctivo": {
        "sesiones": 60,
        "horas": 300.0,
        "costo": 82000.00
      },
      "predictivo": {
        "sesiones": 10,
        "horas": 37.5,
        "costo": 8000.00
      }
    }
  }
}

Authorization

Requires supervisor, reporter, or admin role

Best Practices

Recording Sessions

1

Start Work

Create a session when beginning work on a maintenance task
2

Document Progress

Update descripcion_trabajo with detailed work performed
3

Record Observations

Add observaciones for important findings or issues discovered
4

Track Time

Accurately record horas_trabajadas for proper cost accounting
5

Calculate Costs

Include all labor and material costs in costo_total

Cost Calculation

// Example cost calculation
const hourlyRate = 250.00; // Cost per hour
const horasTrabajadas = 4.5;
const materialCost = 75.00;

const costoTotal = (hourlyRate * horasTrabajadas) + materialCost;
// costoTotal = 1200.00

Session Timing

Create sessions in real-time or shortly after work completion for accuracy
Sessions cannot be created for maintenance with estado=“completado” or “cancelado”

Common Error Responses

Validation Error (422)

{
  "message": "The given data was invalid.",
  "errors": {
    "tecnico_id": ["The tecnico id field is required."],
    "horas_trabajadas": ["The horas trabajadas must be greater than 0."]
  }
}

Maintenance Not Found (404)

{
  "message": "Maintenance record not found"
}

Unauthorized (403)

{
  "message": "You are not authorized to create sessions for this maintenance"
}

Build docs developers (and LLMs) love