How SLA hours are assigned
SLA hours are set at ticket creation by the PostgreSQL functionfn_crear_ticket. The function maps the ticket’s prioridad field to a number of hours according to rules defined in the database. You do not pass sla_horas directly — the API derives it from priority automatically.
POST /tickets/crear.
SLA fields explained
| Field | Type | Description |
|---|---|---|
sla_horas | integer | Total hours allocated for resolution, based on priority. |
fecha_limite_sla | datetime | The absolute deadline: fecha_creacion + sla_horas. |
horas_restantes / horas_restantes_sla | float | Hours remaining until the deadline at the time of the response. Negative if overdue. |
vencido / sla_vencido | boolean | true when the current time has passed fecha_limite_sla. |
The field names differ slightly between the two dashboard endpoints. See the table in the next section for the exact names each endpoint returns.
SLA in dashboard endpoints
Both dashboard endpoints expose SLA data, but they use slightly different field names.- /dashboard
- /dashboard-metricas
The standard dashboard returns a summary row per ticket:
| Field | Notes |
|---|---|
sla_horas | Total hours allocated. |
horas_restantes | Hours left at query time. Negative when overdue. |
vencido | true if the SLA deadline has passed. |
What happens when the SLA expires
When the current server time exceedsfecha_limite_sla:
vencido(dashboard) andsla_vencido(metrics) are set totrue.horas_restantes/horas_restantes_slabecomes a negative number indicating how many hours overdue the ticket is.- The ticket remains in its current state — expiry does not automatically change the ticket workflow.
- You can filter overdue tickets in the dashboard by checking
vencido: true.
Priority and SLA allocation
The mapping betweenprioridad and sla_horas is configured in the database via fn_crear_ticket. The exact values depend on your deployment, but a common baseline is:
Priority (prioridad) | Typical SLA (sla_horas) |
|---|---|
| CRITICA | 4 |
| ALTA | 8 |
| MEDIA | 24 |
| BAJA | 72 |
SLA lifecycle example
Ticket created
A requester submits a ticket with
prioridad: ALTA. fn_crear_ticket calculates sla_horas = 8 and sets fecha_limite_sla = fecha_creacion + 8 hours.Agent checks the dashboard
Three hours after creation, the agent queries
/dashboard. The response shows horas_restantes: 5.0 and vencido: false.SLA deadline passes
Nine hours after creation, the ticket is still open. The dashboard now returns
horas_restantes: -1.0 and vencido: true.