HDB Service uses a four-level organizational hierarchy: Client → Plant → Sector → Location. A client represents a business account. Each client has one or more plants (physical sites). Plants can be subdivided into sectors (logical zones), and each sector contains locations — the precise spots where water dispensers are installed. Locations carry a globally unique, user-defined ID that is printed on QR codes attached to each dispenser mounting point. All endpoints require an authenticated session. Access is automatically scoped by the RBAC system:Documentation 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_RESPONSIBLE and CLIENT_REQUESTER roles can only read data belonging to their own client or assigned plants, and cannot create or modify records.
GET /api/clients
Returns all active clients visible to the authenticated user.CLIENT_RESPONSIBLE and CLIENT_REQUESTER users receive only their own client record. Each client object includes a _count summary with the number of associated plants and users.
Required permission: clients:read
Client ID.
Client display name.
Contact email (nullable).
Contact phone number (nullable).
Physical address (nullable).
Whether the client is active.
ISO 8601 creation timestamp.
| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (clients:read required). |
500 | Internal server error. |
POST /api/clients
Creates a new client. Thenombre field is required; all other fields are optional. Creation is idempotent via the Idempotency-Key header — sending the same key twice returns the first response without creating a duplicate. The action is written to the audit log.
Required permission: clients:write
Client display name. Cannot be blank.
Contact email address.
Contact phone number.
Physical address.
Newly created client ID.
Client display name.
Contact email (nullable).
Contact phone (nullable).
Physical address (nullable).
Always
true on creation.ISO 8601 creation timestamp.
| Status | Description |
|---|---|
400 | nombre is missing or blank. |
401 | Not authenticated. |
403 | Insufficient permission (clients:write required). |
500 | Internal server error. |
GET /api/clients/[id]
Returns a single client by ID, including its active plants (each with a count of locations), the total number of associated users, and the client’s SLA configuration if one exists. Returns403 if the authenticated user does not have access to this client.
Required permission: clients:read
Client ID.
Client display name.
Contact email (nullable).
Contact phone (nullable).
Physical address (nullable).
Whether the client is active.
SLA configuration object (nullable). See SLA Config schema for full field list.
| Status | Description |
|---|---|
403 | Authenticated user does not have access to this client. |
404 | Client not found. |
401 | Not authenticated. |
500 | Internal server error. |
PUT /api/clients/[id]
Updates one or more fields on an existing client. Only fields present in the request body are updated; omitted fields are left unchanged. Settingactive: false effectively deactivates the client. All changes are recorded in the audit log.
Required permission: clients:write
New client display name.
New contact email. Pass
null to clear.New contact phone. Pass
null to clear.New physical address. Pass
null to clear.Set to
false to deactivate the client.Client ID.
Updated display name.
Updated email (nullable).
Updated phone (nullable).
Updated address (nullable).
Current active state.
ISO 8601 last-updated timestamp.
| Status | Description |
|---|---|
404 | Client not found. |
401 | Not authenticated. |
403 | Insufficient permission (clients:write required). |
500 | Internal server error. |
DELETE /api/clients/[id]
Soft-deletes a client by settingactive: false. The client record and all related data are retained in the database. The action is recorded in the audit log.
Required permission: clients:write
Client ID.
Always
false after a successful delete.ISO 8601 timestamp of deactivation.
| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (clients:write required). |
500 | Internal server error. |
GET /api/plants
Returns all active plants visible to the authenticated user.CLIENT_RESPONSIBLE users see only plants belonging to their client. CLIENT_REQUESTER users see only plants they have been explicitly granted access to via UserPlantAccess. Each plant includes a reference to its parent client and a count of locations.
Required permission: plants:read
Filter plants by client ID.
Plant ID.
Owning client ID.
Plant display name.
Physical address (nullable).
Latitude coordinate (nullable).
Longitude coordinate (nullable).
Whether the plant is active.
ISO 8601 creation timestamp.
| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (plants:read required). |
500 | Internal server error. |
POST /api/plants
Creates a new plant under an existing client. Requires bothclientId and nombre. The optional lat / lng fields enable map-based features in the UI. Creation is idempotent via Idempotency-Key. The action is recorded in the audit log.
Required permission: plants:write
ID of the parent client.
Plant display name. Cannot be blank.
Physical address of the plant site.
Latitude coordinate for map display.
Longitude coordinate for map display.
Newly created plant ID.
Parent client ID.
Plant display name.
Physical address (nullable).
Latitude (nullable).
Longitude (nullable).
Always
true on creation.ISO 8601 creation timestamp.
| Status | Description |
|---|---|
400 | clientId or nombre is missing. |
401 | Not authenticated. |
403 | Insufficient permission (plants:write required). |
500 | Internal server error. |
PUT /api/plants/[id]
Updates one or more fields on an existing plant. Only fields present in the request body are updated. Settingactive: false effectively deactivates the plant. All changes are recorded in the audit log.
Required permission: plants:write
New display name.
New address. Pass
null to clear.Reassign to a different client.
Set to
false to deactivate the plant.Plant ID.
Updated display name.
Current active state.
ISO 8601 last-updated timestamp.
| Status | Description |
|---|---|
404 | Plant not found. |
401 | Not authenticated. |
403 | Insufficient permission (plants:write required). |
500 | Internal server error. |
DELETE /api/plants/[id]
Soft-deletes a plant by settingactive: false. The plant record and all related data are retained in the database. The action is recorded in the audit log.
Required permission: plants:write
Plant ID.
Always
false after a successful delete.ISO 8601 timestamp of deactivation.
| Status | Description |
|---|---|
404 | Plant not found. |
401 | Not authenticated. |
403 | Insufficient permission (plants:write required). |
500 | Internal server error. |
GET /api/locations
Returns all active locations. Results are sorted naturally by plant name then location name. Each location includes its parent plant (with client name), its sector (if assigned), and any dispenser currently inIN_SERVICE status at that location.
Required permission: locations:read
Filter locations to a specific plant.
Filter locations to a specific sector.
Location ID (user-defined, globally unique).
Parent plant ID.
Sector ID (nullable).
Location display name.
Floor identifier (nullable).
Area within the sector (nullable).
Free-text description (nullable).
Whether the location is active.
Array of dispensers currently at this location with
status: IN_SERVICE. Each entry includes id, marca, modelo, and status.| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (locations:read required). |
500 | Internal server error. |
POST /api/locations
Creates a new location. Theid field is the globally unique location code printed on QR codes — you may supply your own (e.g., "A-102") or omit it to have the server auto-generate a sequential ID in the format LOC-001, LOC-002, etc. The plantId and nombre are always required. Creation is idempotent via Idempotency-Key. The action is recorded in the audit log.
Required permission: locations:write
User-defined globally unique location ID (e.g.,
"SECTOR-A-101"). If omitted or blank, the server auto-generates a sequential LOC-NNN ID.ID of the parent plant.
Location display name. Cannot be blank.
ID of the sector this location belongs to.
Floor identifier (e.g.,
"2", "PB", "Mezzanine").Area within the sector (e.g.,
"Sala de reuniones").Free-text description for technicians.
Location ID (user-supplied or auto-generated).
Parent plant ID.
Sector ID (nullable).
Location display name.
Floor (nullable).
Area (nullable).
Description (nullable).
Always
true on creation.ISO 8601 creation timestamp.
| Status | Description |
|---|---|
400 | plantId or nombre is missing. |
409 | Supplied id already exists in the system. |
401 | Not authenticated. |
403 | Insufficient permission (locations:write required). |
500 | Internal server error. |
PUT /api/locations/[id]
Updates one or more fields on an existing location. Only fields present in the request body are modified. Settingactive: false deactivates the location. Changes are recorded in the audit log.
Required permission: locations:write
New display name.
Reassign to a different plant.
Reassign to a different sector. Pass
null to remove sector assignment.Updated floor. Pass
null to clear.Updated area. Pass
null to clear.Updated description. Pass
null to clear.Set to
false to deactivate the location.Location ID.
Updated display name.
Current active state.
ISO 8601 last-updated timestamp.
| Status | Description |
|---|---|
404 | Location not found. |
401 | Not authenticated. |
403 | Insufficient permission (locations:write required). |
500 | Internal server error. |
DELETE /api/locations/[id]
Soft-deletes a location by settingactive: false. The location record is retained in the database. The action is recorded in the audit log.
Required permission: locations:write
Location ID.
Always
false after a successful delete.ISO 8601 timestamp of deactivation.
| Status | Description |
|---|---|
404 | Location not found. |
401 | Not authenticated. |
403 | Insufficient permission (locations:write required). |
500 | Internal server error. |
GET /api/sectors
Returns all active sectors. WhenplantId is provided, returns only sectors associated with that plant via the PlantSector junction table. Without a plantId, returns all sectors with counts of associated locations and plants.
Required permission: sectors:read
Filter to sectors assigned to a specific plant.
Sector ID.
Sector display name.
Optional description (nullable).
Whether the sector is active.
ISO 8601 creation timestamp.
Present when no
plantId filter is applied.| Status | Description |
|---|---|
401 | Not authenticated. |
403 | Insufficient permission (sectors:read required). |
500 | Internal server error. |
POST /api/sectors
Creates a new sector. Sectors are reusable across plants — the same sector can be assigned to multiple plants via thePlantSector join table. Creation is idempotent via Idempotency-Key. The action is recorded in the audit log.
Required permission: sectors:write
Sector display name. Cannot be blank.
Optional free-text description.
Newly created sector ID.
Sector display name.
Description (nullable).
Always
true on creation.ISO 8601 creation timestamp.
| Status | Description |
|---|---|
400 | nombre is missing or blank. |
401 | Not authenticated. |
403 | Insufficient permission (sectors:write required). |
500 | Internal server error. |
PUT /api/sectors/[id]
Updates one or more fields on an existing sector. Only fields present in the request body are modified. Settingactive: false deactivates the sector. Changes are recorded in the audit log.
Required permission: sectors:write
New display name.
Updated description. Pass
null to clear.Set to
false to deactivate the sector.Sector ID.
Updated display name.
Updated description (nullable).
Current active state.
ISO 8601 last-updated timestamp.
| Status | Description |
|---|---|
404 | Sector not found. |
401 | Not authenticated. |
403 | Insufficient permission (sectors:write required). |
500 | Internal server error. |
DELETE /api/sectors/[id]
Soft-deletes a sector by settingactive: false. The sector record is retained in the database. The action is recorded in the audit log.
Required permission: sectors:write
Sector ID.
Always
false after a successful delete.ISO 8601 timestamp of deactivation.
| Status | Description |
|---|---|
404 | Sector not found. |
401 | Not authenticated. |
403 | Insufficient permission (sectors:write required). |
500 | Internal server error. |