Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/123048152-JJDS/CafeteriaPM_S203/llms.txt

Use this file to discover all available pages before exploring further.

The /mesas/ endpoints manage the physical dining tables in the cafeteria. Rather than storing status as a column, table state is computed on every request by checking whether an active order exists for the table. This means the values disponible, ocupada, and reservada always reflect the real-time state of the system, and there is no risk of stale flags. All state changes — occupying, releasing, reserving, or cancelling a reservation — work by creating or transitioning the underlying order, not by updating a status field on the table itself.

Endpoints

List all tables

Authorization
string
required
Bearer <token> — Any authenticated user.

GET /mesas/
Returns every table in the system along with its current computed status and the active order ID (if any). Results are unordered by default.
id
integer
Internal table ID.
numero
integer
Display table number shown to staff.
capacidad
integer
Maximum seating capacity.
estado
string
Live status: disponible, ocupada, or reservada.
pedido_activo_id
integer | null
ID of the active order, or null if the table is available.
Example response
[
  {
    "id": 1,
    "numero": 3,
    "capacidad": 4,
    "estado": "disponible",
    "pedido_activo_id": null
  },
  {
    "id": 2,
    "numero": 7,
    "capacidad": 2,
    "estado": "ocupada",
    "pedido_activo_id": 58
  }
]

Get a single table

Authorization
string
required
Bearer <token> — Any authenticated user.

GET /mesas/{mesa_id}
mesa_id
integer
required
Internal ID of the table to retrieve.
Returns the same MesaOut shape as the list endpoint. Returns 404 if no table with that ID exists. Example response
{
  "id": 5,
  "numero": 12,
  "capacidad": 6,
  "estado": "reservada",
  "pedido_activo_id": 63
}
Error responses
StatusDetail
404"Mesa no encontrada"

Get a table by display number

Authorization
string
required
Bearer <token> — Any authenticated user.

GET /mesas/por-numero/{numero}
Looks up a table by the numero field — the human-readable display number that staff reference on the floor. This is distinct from the internal id.
numero
integer
required
The display number assigned to the table (e.g. 5 for “Table 5”).
Error responses
StatusDetail
404"Mesa número {numero} no encontrada"

Create a table

Authorization
string
required
Bearer <token> — Role: admin.

POST /mesas/
Creates a new table. The numero must be unique across all tables. The new table is returned with estado: "disponible" and pedido_activo_id: null. Request body
numero
integer
required
Display table number. Must be unique. Cannot be changed after creation.
capacidad
integer
required
Maximum seating capacity for the table (number of guests).
{
  "numero": 5,
  "capacidad": 4
}
Response201 Created
{
  "id": 9,
  "numero": 5,
  "capacidad": 4,
  "estado": "disponible",
  "pedido_activo_id": null
}
Error responses
StatusDetail
400"Ya existe una mesa con el número {numero}"

Delete a table

Authorization
string
required
Bearer <token> — Role: admin.

DELETE /mesas/{mesa_id}
mesa_id
integer
required
Internal ID of the table to delete.
Permanently removes a table. The request is rejected if the table is currently ocupada or reservada — the active order must be closed first. It is also rejected if the table has historical (completed) orders linked to it, preserving referential integrity. Response204 No Content Error responses
StatusDetail
404"Mesa no encontrada"
400"No se puede eliminar la mesa porque está {estado}. Primero debe cerrar el pedido #{pedido_id}."
400"No se puede eliminar la mesa porque tiene pedidos históricos asociados." (raised on IntegrityError)

Occupy a table

Authorization
string
required
Bearer <token> — Roles: admin, mesero.

PATCH /mesas/{mesa_id}/ocupar
mesa_id
integer
required
Internal ID of the table to mark as occupied.
Marks a table as occupied by creating a new Order record in pendiente state, linked to the table and the calling user as the assigned waiter. The response includes the new order’s ID so the caller can immediately begin adding items to it. Response
{
  "message": "Mesa ocupada correctamente",
  "pedido_id": 72
}
Error responses
StatusDetail
404"Mesa no encontrada"
400"La mesa ya está ocupada"
500"Estado 'pendiente' no configurado" (system misconfiguration)

Release a table

Authorization
string
required
Bearer <token> — Roles: admin, mesero, caja.

PATCH /mesas/{mesa_id}/liberar
mesa_id
integer
required
Internal ID of the table to release.
Forcefully releases a table by transitioning its active order directly to pagado status, bypassing the normal payment flow through /ventas/. An OrderStatusHistory record is written to audit the transition. Use this endpoint for quick cleanup operations rather than as a substitute for proper payment registration. Note that this endpoint only acts on orders in pendiente, en_preparacion, listo, or entregado states — a table in reservada state cannot be released with this endpoint; use PATCH /mesas/{mesa_id}/cancelar-reserva instead. Response
{
  "message": "Mesa liberada correctamente",
  "pedido_id": 72
}
Error responses
StatusDetail
404"Mesa no encontrada"
400"La mesa no tiene pedido activo"
500"Estado 'pagado' no configurado" (system misconfiguration)

Reserve a table

Authorization
string
required
Bearer <token> — Roles: admin, mesero.

PATCH /mesas/{mesa_id}/reservar
mesa_id
integer
required
Internal ID of the table to reserve.
Places a reservation on a table by creating a new Order in reservado state. Only tables with estado: "disponible" can be reserved — occupied tables and tables with an existing reservation both return 400. Response
{
  "message": "Mesa reservada correctamente",
  "pedido_id": 75
}
Error responses
StatusDetail
404"Mesa no encontrada"
400"La mesa no está disponible para reservar"
500"Estado 'reservado' no configurado" (system misconfiguration)

Cancel a reservation

Authorization
string
required
Bearer <token> — Roles: admin, mesero.

PATCH /mesas/{mesa_id}/cancelar-reserva
mesa_id
integer
required
Internal ID of the table whose reservation should be cancelled.
Cancels the active reservation on a table. The reservado order is transitioned to cancelado status (or deleted if the cancelado status is not configured). After cancellation the table’s computed status returns to disponible. Response
{
  "message": "Reserva cancelada correctamente"
}
Error responses
StatusDetail
404"Mesa no encontrada"
400"La mesa no tiene una reserva activa"

The MesaOut object

Every read endpoint returns a MesaOut object. The estado and pedido_activo_id fields are computed dynamically on each request and are never persisted as columns.
id
integer
Internal table ID.
numero
integer
Display table number shown to staff.
capacidad
integer
Maximum seating capacity.
estado
string
Live status: disponible, ocupada, or reservada.
pedido_activo_id
integer | null
ID of the active order, or null if the table is available.

Table status state machine

The estado value is derived from the order linked to the table, not from any stored field. The full lifecycle looks like this:
disponible ──── /ocupar ────▶ ocupada
disponible ──── /reservar ──▶ reservada
reservada  ── /cancelar-reserva ──▶ disponible
ocupada    ──── /liberar ───▶ disponible (via pagado)
An order in states pendiente, en_preparacion, listo, or entregado yields "ocupada". An order in reservado state yields "reservada". No active order in any of those states means "disponible".

Build docs developers (and LLMs) love