The tables (mesas) API manages the complete lifecycle of every billiard table in the hall: creating and configuring tables, opening and closing player sessions with automatic billing calculation, editing table properties, and removing tables from service. All seven endpoints require a valid JWT bearer token in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ierinconc/billar-pro-backend/llms.txt
Use this file to discover all available pages before exploring further.
Authorization header — see the Authentication page to obtain one.
Table object
Every endpoint that returns a table uses the following schema:Auto-generated primary key for the table record.
The table’s display number within the hall. Must be unique among all active tables.
Current occupancy state of the table. One of
"LIBRE" (available) or "OCUPADA" (in use).Hourly rate for this table in the local currency. Must be greater than
0.ISO-8601 datetime at which the current session started.
null when estado is "LIBRE".Whether the table is active. Only tables with
activa = true are returned by the list endpoint. A table with session history is soft-deleted by setting this to false.GET /api/mesas
Returns a list of all active tables (activa = true). Tables that have been soft-deleted are excluded.
Auth required: Yes
Example request
Example response (HTTP 200)
POST /api/mesas
Creates a new billiard table. The table is initialized withestado = "LIBRE" and activa = true.
Auth required: Yes
Request body
The display number for the new table. Must be unique among all currently active tables — the service checks
existsByNumeroAndActivaTrue before saving.The hourly billing rate for the table. Must be provided and strictly greater than
0.Example request
Example response (HTTP 200)
Validation errors (HTTP 404)
| Condition | mensaje |
|---|---|
Another active table already has this numero | "Ya existe una mesa activa con ese número" |
precioPorHora is missing (null) | "El precio de la hora por mesa es obligatorio" |
precioPorHora is <= 0 | "El precio del tiempo por mesa debe ser mayor a 0" |
GET /api/mesas/
Returns a single table by its primary key ID. Auth required: YesPath parameter
The primary key (
id) of the table to retrieve.Example request
Example response (HTTP 200)
Error (HTTP 404)
If no table with the given ID exists, the server returns:PUT /api/mesas//ocupar
Opens a new playing session on a table. Setsestado to "OCUPADA" and records horaInicio as the current server time (LocalDateTime.now()). This timestamp is later used by the close endpoint to compute billing.
Auth required: Yes
Path parameter
The primary key of the table to open.
Example request
Example response (HTTP 200)
Error (HTTP 400)
If the table is already"OCUPADA", a NegocioException is thrown:
PUT /api/mesas//cerrar
Closes the current session on a table, computes the bill, creates aSesion record (linking any pending consumptions to it), and resets the table to "LIBRE". Returns a billing summary DTO instead of the raw Mesa object.
Auth required: Yes
Billing calculation
The service computes the charge using fractional hours based on elapsed minutes:totalGeneral is the sum of totalAPagar (table time) and totalConsumos (any consumptions linked to the session).
Path parameter
The primary key of the table to close.
Example request
Response fields
Total elapsed time in fractional hours (e.g.
1.5 for 90 minutes).The hourly rate that was applied to this session, taken from the table record.
The table-time charge:
horasJugadas × precioPorHora.The sum of all consumptions linked to this session (drinks, snacks, etc.).
Grand total:
totalAPagar + totalConsumos.Example response (HTTP 200)
Error (HTTP 400)
If the table is already"LIBRE" (no active session to close), a NegocioException is thrown:
PUT /api/mesas/
Updates thenumero and precioPorHora of an existing table. The table must be in "LIBRE" state — editing an in-use table is not allowed.
Auth required: Yes
Path parameter
The primary key of the table to edit.
Request body
The new display number to assign to the table.
The new hourly rate to apply to future sessions.
Example request
Example response (HTTP 200)
Error (HTTP 404)
If the table is currently"OCUPADA", the operation is rejected:
DELETE /api/mesas//delete
Removes a table from service. The deletion strategy depends on whether the table has any historical session records:- No sessions → the table row is permanently deleted from the database (
deleteById). - Has sessions → the table is soft-deleted:
activais set tofalseand the record is kept for historical integrity. The table will no longer appear inGET /api/mesas.
Path parameter
The primary key of the table to delete or deactivate.
Example request
Response (HTTP 204 No Content)
An empty body is returned regardless of whether the table was physically deleted or soft-deleted.Tables that have at least one linked session are never physically deleted. Setting
activa = false preserves the full session history and billing records for auditing while hiding the table from active operations. To check whether a table was soft-deleted, query it directly via GET /api/mesas/{id} — the activa field will be false.Error (HTTP 404)
If no table with the given ID exists:Error response schema
Business-rule violations (NegocioException) return HTTP 400; not-found and other RuntimeExceptions return HTTP 404. Both use the same envelope shape from GlobalExceptionHandler:
ISO-8601 local datetime of when the error occurred.
HTTP status code —
400 for business errors, 404 for not-found errors.Error category:
"Error de negocio" (400) or "Recurso no encontrado" (404).Specific description of what went wrong.