The ticketing system is the primary channel for reporting and resolving service incidents across the water dispenser fleet. Any authenticated user — from an on-floorDocumentation 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.
CLIENT_REQUESTER to an ADMIN — can open a ticket against a dispenser or a location. From the moment a ticket is created, HDB Service automatically calculates SLA deadlines, routes push and email notifications, and maintains a full audit trail of every status transition and comment.
Creating a ticket
Tickets are created viaPOST /api/tickets. The minimum required field is reason; all other fields are optional or auto-resolved.
| Field | Required | Default | Description |
|---|---|---|---|
dispenserId | No | — | ID of the affected dispenser. |
locationId | No | Auto-resolved | If omitted but dispenserId is provided, the location is automatically resolved from the dispenser’s current locationId. |
reason | Yes | — | Short description of the incident. |
description | No | null | Optional detailed explanation. |
priority | No | MEDIUM | LOW, MEDIUM, HIGH, or CRITICAL. |
wantsPushNotifications | No | false | If true, the requester opts into push notifications for updates on this ticket. |
wantsEmailNotifications | No | false | If true, the requester opts into email notifications for updates on this ticket. |
SlaConfig record for the client associated with the resolved location. Using that configuration (or system-wide defaults if none is found), it calculates and stores both slaResponseDeadline and slaResolutionDeadline on the ticket.
Default SLA times (in minutes):
| Priority | Response | Resolution |
|---|---|---|
LOW | 480 min (8 h) | 4 320 min (72 h) |
MEDIUM | 240 min (4 h) | 1 440 min (24 h) |
HIGH | 120 min (2 h) | 480 min (8 h) |
CRITICAL | 60 min (1 h) | 240 min (4 h) |
SLA deadlines are fixed at creation time based on the client’s configuration at that moment. Changing
SlaConfig later does not retroactively affect open tickets.Ticket statuses
Every ticket moves through a defined lifecycle. Each transition is recorded inTicketStatusHistory with the fromStatus, toStatus, the name of the user who made the change (changedBy), a timestamp (changedAt), and an optional notes string.
OPEN
The ticket has been created and is awaiting acknowledgement. This is the initial state for all new tickets. The SLA response clock is ticking.
IN_PROGRESS
A technician has begun working on the ticket. The first transition to
IN_PROGRESS records respondedAt and checks whether slaResponseDeadline was already breached.RESOLVED
The technician has fixed the issue.
resolvedAt is recorded and slaResolutionBreached is evaluated. An email is sent to the requester upon resolution.CLOSED
The ticket has been formally closed by an ADMIN or SUPERVISOR. If closed without first reaching
RESOLVED, push and in-app notifications are sent to the original reporter and all supervisors.statusHistory array on GET /api/tickets/[id], ordered chronologically.
Priority and SLA
Priority is set at ticket creation and can be updated viaPUT /api/tickets/[id] by users with tickets:write. It determines both the urgency display in the UI and the SLA deadline windows.
The slaStatus query parameter on GET /api/tickets allows filtering by breach state:
slaStatus value | Behaviour |
|---|---|
BREACHED | Returns tickets where slaResolutionBreached = true. |
NEAR_BREACH | Returns non-closed tickets (OPEN, IN_PROGRESS, or RESOLVED) whose slaResolutionDeadline falls within the next 2 hours and have not yet been breached. |
| (omitted) | No SLA filter applied. |
slaResponseBreached— set totruewhen the ticket transitions toIN_PROGRESSafter itsslaResponseDeadlinehas passed.slaResolutionBreached— set totruewhen the ticket transitions toRESOLVEDorCLOSEDafter itsslaResolutionDeadlinehas passed.
Assignment
Tickets are assigned to a singleTECHNICIAN-role user via the assignedToId field. Assignment can be set or changed by users holding the tickets:assign permission.
- A push notification is sent to the technician via OneSignal (if they have a registered
onesignalPlayerId). - An in-app notification is created in the
Notificationtable for the technician. - An email is sent to the technician using the
TICKET_ASSIGNEDtemplate, including priority and SLA deadline.
TECHNICIAN users can only see tickets that are directly assigned to them (
assignedToId = user.id). Technicians also cannot update the assignedToId field — that requires tickets:assign.PUT /api/tickets/[id]: if a technician attempts to update a ticket that is not assigned to them, the API returns 403 Forbidden.
Comments
Any user withtickets:read access can add a comment to a ticket. Comments are stored in TicketComment and are returned as part of the GET /api/tickets/[id] response, ordered by createdAt ascending.
PUT or DELETE endpoint for individual comments. This preserves the integrity of the audit trail.
Notifications on ticket creation
When a ticket is created, HDB Service fires notifications on three channels simultaneously:In-app notifications
A
Notification record is created in the database for every active ADMIN and SUPERVISOR user. These appear in the bell icon notification panel in the UI.OneSignal push notifications
All
ADMIN and SUPERVISOR users who have a registered onesignalPlayerId receive a push notification with the ticket priority and the first 100 characters of the reason.RESOLVED (using the TICKET_RESOLVED template), regardless of the wantsEmailNotifications preference.
Required permissions
| Permission | Roles |
|---|---|
tickets:read | ADMIN, SUPERVISOR, TECHNICIAN, CLIENT_RESPONSIBLE, CLIENT_REQUESTER |
tickets:write | ADMIN, SUPERVISOR, TECHNICIAN, CLIENT_RESPONSIBLE, CLIENT_REQUESTER |
tickets:assign | ADMIN, SUPERVISOR |
tickets:close | ADMIN, SUPERVISOR |