Every ticket created in HDB Service is automatically assigned two SLA deadlines — a response deadline and a resolution deadline — calculated from the ticket’s creation timestamp and its priority level. These deadlines are tracked in real time: the system continuously evaluates whether a ticket is on track, approaching a breach, or already breached, and sends notifications to ADMIN and SUPERVISOR users accordingly. All SLA logic lives inDocumentation 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.
lib/sla.ts and the associated SlaConfig Prisma model.
SLA configuration
SLA time limits are configured per Client via theSlaConfig model. A Client without a custom config automatically falls back to the platform defaults. Each config stores independent response and resolution times (in minutes) for each of the four ticket priorities.
Default SLA values
The platform defaults (fromlib/sla.ts) apply when no client-specific config exists:
| Priority | Response Time | Resolution Time |
|---|---|---|
LOW | 480 min (8 h) | 4320 min (72 h) |
MEDIUM | 240 min (4 h) | 1440 min (24 h) |
HIGH | 120 min (2 h) | 480 min (8 h) |
CRITICAL | 60 min (1 h) | 240 min (4 h) |
Deadline calculation
When a ticket is created,calculateSlaDeadlines() is called with the creation timestamp, the ticket’s priority, and the client’s SLA config (or null to use platform defaults). It returns both deadlines, which are stored on the Ticket row as slaResponseDeadline and slaResolutionDeadline.
Function signature:
getResponseTime() and getResolutionTime() helpers (also exported from lib/sla.ts) to look up the correct minutes for the given priority and config, then uses date-fns addMinutes() to produce the deadline timestamps.
SLA status
At any point in a ticket’s life, its SLA status can be one of three values:| Status | Meaning |
|---|---|
ON_TIME | Elapsed time is below the near-breach threshold — the ticket is progressing within SLA. |
NEAR_BREACH | Elapsed time has exceeded nearBreachPercent% of the total SLA window but the deadline has not yet passed. |
BREACHED | The deadline timestamp is in the past — the SLA has been missed. |
nearBreachPercent (default 80%). For example, on a HIGH priority response window of 120 minutes, NEAR_BREACH is triggered once 96 minutes (80% × 120) have elapsed.
Function signature:
Breach detection
HDB Service runs a scheduled cron job daily at 2 AM that scans all open tickets (OPEN or IN_PROGRESS) and evaluates their SLA deadlines against the current time. For each ticket the job:
Check response breach
If
slaResponseDeadline is in the past and slaResponseBreached is still false, the field is set to true and the ticket record is updated.Check resolution breach
If
slaResolutionDeadline is in the past and slaResolutionBreached is still false, the field is set to true and the ticket record is updated.slaResponseBreached and slaResolutionBreached boolean fields on the Ticket model are the authoritative breach markers used for reporting, dashboard metrics, and SLA compliance calculations.
SLA filtering in the API
TheGET /api/tickets endpoint accepts a slaStatus query parameter that filters the result set to tickets currently in the requested SLA state. The status is computed at query time using getSlaStatus() — it is not stored as a column.
slaStatus value | Returns |
|---|---|
ON_TIME | Open tickets where elapsed time is below the near-breach threshold |
NEAR_BREACH | Open tickets past the threshold but deadline not yet expired |
BREACHED | Tickets whose resolution deadline has passed (or slaResolutionBreached === true) |
HIGH priority tickets that are currently approaching their SLA deadline — useful for supervisor dashboards and proactive escalation workflows.