The Dashboard API surfaces aggregated, role-aware analytics over the entire HDB Service fleet. All endpoints enforce theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/GianlucaBessone/HDB-Service/llms.txt
Use this file to discover all available pages before exploring further.
dashboard:read permission so data is automatically scoped to what the authenticated user is allowed to see: ADMIN and SUPERVISOR users can query across all clients and plants; TECHNICIAN users see only tickets assigned to them; CLIENT_RESPONSIBLE users see only data for their own client; CLIENT_REQUESTER users see their own reported tickets plus their assigned plants. Passing an optional plantId query parameter further narrows results to a single plant.
The five endpoints below cover progressively deeper layers of analysis — from a one-screen operational summary all the way to a downloadable PDF maintenance report.
GET /api/dashboard
Returns a high-level operational summary for the authenticated user. All counts are computed in parallel usingPromise.all to minimize latency. SLA compliance is calculated using the shared calculateSlaCompliance utility, which measures the proportion of resolved tickets that met their resolution deadline.
Required permission: dashboard:read
Restrict all counts to a specific plant. Non-admin/supervisor users are blocked from querying plants they do not have access to.
| Status | Description |
|---|---|
403 | Non-admin user requested a plantId they do not have access to. |
401 | Not authenticated. |
403 | Insufficient permission (dashboard:read required). |
500 | Internal server error. |
GET /api/dashboard/analytics
Returns deep analytical KPIs and fleet health data. This endpoint queries tickets, repair histories, maintenance checklists, and dispenser records simultaneously to compute: SLA (average hours from ticket creation to first technical action), MTTR (mean time to repair in hours), MTBF (mean time between failures in days), top failure modes extracted from maintenance checklistfallas arrays, and a health score for each dispenser. Dispenser health is scored 0–100 using a weighted algorithm that considers MTBF, MTTR, repair recurrences, average condition rating from checklists, and lifecycle progress.
Required permission: dashboard:read
Filter to a specific client.
Filter to a specific plant.
Filter to a specific sector.
Filter to a single dispenser.
All KPI values are rounded to one decimal place. If no resolved tickets exist in scope,
sla and mttr return 0. If a dispenser has had only one repair event, its MTBF contribution is excluded (at least two repair events are needed to measure a gap).| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (dashboard:read required). |
500 | Internal server error computing analytics. |
GET /api/dashboard/performance
Returns time-series performance KPIs over the past 6 months, broken down by calendar month. In addition to the three global KPIs (SLA, MTTR, MTBF), this endpoint provides a month-by-monthtimeline array and a ranked list of the top 10 failure modes. An optional failureName filter restricts the KPI and timeline calculations to tickets related to a specific failure type (matched by cross-referencing the ticket’s dispenser and creation time against maintenance checklist records within a ±7-day window).
Required permission: dashboard:read
Filter to a specific client.
Filter to a specific plant.
Filter KPIs and timeline to tickets associated with a specific failure mode name (matched against maintenance checklist
fallas arrays).Top 10 failure modes sorted by frequency. Each entry includes
name, count, avgRepairTime (hours), and severity (HIGH or MEDIUM).Six entries, one per calendar month (oldest first). Each entry:
month(string): short month + year label (e.g.,"Jan 2025").sla(number): average SLA hours for that month (0if no data).mttr(number): average MTTR hours for that month (0if no data).
| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (dashboard:read required). |
500 | Internal server error computing performance data. |
GET /api/dashboard/salud
Returns a detailed per-dispenser health ranking for the entire fleet (or a scoped subset). Each dispenser receives a composite health score (0–100) computed using a weighted algorithm: MTBF contributes 40%, MTTR 20%, repair recurrences in the last 180 days 20%, average general condition rating from maintenance checklists 10%, and lifecycle age progress 10%. Dispensers are returned sorted worst-first. The response is cached withs-maxage=300 (5 minutes) and stale-while-revalidate=60.
Required permission: dashboard:read
Filter to a specific client.
Filter to a specific plant.
All in-scope dispensers sorted ascending by health score (worst first). Each entry includes:
6-month trend of the fleet’s global average health score. Each entry has
month (short Spanish month name) and score (number, 0–100).| Status | Description |
|---|---|
403 | Non-admin user requested a plantId or clientId they do not have access to. |
401 | Not authenticated. |
403 | Insufficient permission (dashboard:read required). |
500 | Internal server error. |
POST /api/dashboard/pdf
Generates and returns a PDF maintenance report as a binary file stream. The PDF is rendered server-side using@react-pdf/renderer. The report layout varies by type: performance reports display SLA, MTTR, and MTBF KPIs plus a top-failures table; salud reports display the fleet health distribution and a ranked dispenser table (top 10 worst). Applied filter labels are printed in the report header. The binary response should be downloaded directly, not parsed as JSON.
Required permission: reports:generate
This endpoint accepts a
POST request. The analytics data to render must be fetched separately from /api/dashboard/analytics or /api/dashboard/salud and passed in the data field of the request body.Report type. One of
performance (renders KPIs and failure analysis) or salud (renders fleet health distribution and dispenser ranking).Filters to display in the report header.
The analytics payload to render. For
type: "performance", pass the response from GET /api/dashboard/performance. For type: "salud", pass the response from GET /api/dashboard/salud.| Header | Value |
|---|---|
Content-Type | application/pdf |
Content-Disposition | attachment; filename="Reporte_<type>.pdf" |
| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (reports:generate required). |
500 | PDF rendering failed (plain text error response, not JSON). |