The Orders API covers the full lifecycle of a dining order in La Comanda — from the moment a waiter submits items at the table through kitchen preparation, service delivery, and the final admin-level audit trail. Each endpoint enforces role-based access so that only the appropriate staff can perform each action.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JAQA20/LaComanda/llms.txt
Use this file to discover all available pages before exploring further.
All endpoints in this section require an active PHP session cookie
(
PHPSESSID). Missing or expired sessions receive an HTTP redirect to
views/login.php instead of a JSON error response.POST /public/api/guardarOrden.php
Creates a new order, resolves each product name against the catalog, splits items into kitchen and barista sub-orders, and persists everything to MySQL viaOrdenesSync::guardarEnBase().
Method: POST
Auth: rol_id IN (1 Admin, 2 Mesero)
Content-Type: application/json
Request Body
Send the body as a JSON object.The table number as a string (e.g.
"3"). Must be castable to an integer
greater than zero; "0" or non-numeric values return 400.Newline-separated list of items, each in the format Each product name is looked up in the
"Product Name x Quantity".
Example:productos table. An unrecognized name
returns 400.Free-text notes for the kitchen or barista. Optional; defaults to an empty
string if omitted.
Response
"OK" on success.The auto-assigned order number (
numero_orden) for the new order. Use this
value to reference the order in subsequent calls.| HTTP Status | Condition |
|---|---|
400 Bad Request | Request body is not valid JSON |
400 Bad Request | mesa is 0 or non-numeric |
400 Bad Request | items is empty after normalization |
400 Bad Request | A product name in items is not found in the catalog |
500 Internal Server Error | Database exception during insert |
Example
GET /public/api/obtenerOrdenes.php
Returns all active kitchen orders — items that belong to non-barista categories and have not yet reachedestado_item = 'entregado'. This endpoint powers the live kitchen display.
Method: GET
Auth: rol_id IN (1 Admin, 3 Cocina)
Response
true on success.Array of order objects, each containing:
id_orden(integer) — internal database IDnumero(integer) — human-readable order number shown on kitchen ticketsmesa(string) — table numberitems(array) — line items with product name, quantity, andestado_itemestado(string) — aggregate order status:pendiente,en_preparacion, orlisto
500):
Example
POST /public/api/entregarOrden.php
Marks the active sub-order for a given table and preparation area as delivered. Used by waiters to confirm that food or drinks have reached the table, freeing the table for new orders when both areas are delivered. Method:POST
Auth: rol_id IN (1 Admin, 2 Mesero)
Content-Type: application/x-www-form-urlencoded
Request Parameters
The table number. Must be greater than zero; missing or zero values return
400.The preparation area for the sub-order:
"cocina" or "barista". When
omitted, the delivery applies to all areas for the table.Response
"OK" on success.Confirmation message:
"Sub-orden entregada correctamente".The table number echoed back as a string.
The area echoed back (
"cocina", "barista", or empty string).| HTTP Status | Condition |
|---|---|
400 Bad Request | mesa is missing or zero |
400 Bad Request | No active order found for the given table / area |
405 Method Not Allowed | Request method is not POST |
Example
POST /public/api/marcarEntrega.php
Marks an entire order asentregada and frees the associated table. Called from the kitchen view when the kitchen confirms that an order is fully complete. On success (and on most error conditions), the server issues an HTTP redirect to views/cocina.php.
Method: POST
Auth: rol_id IN (1 Admin, 3 Cocina)
Content-Type: application/x-www-form-urlencoded
Request Parameters
The order number (
numero_orden) to mark as delivered. Values ≤ 0 result in
a redirect to views/cocina.php without processing.Response
This endpoint does not return JSON. All outcomes redirect toviews/cocina.php:
Example
GET /public/api/ordenesAdminData.php
Returns the complete order history for the admin panel, with each order’s items, per-area sub-order statuses, computed aggregate status, and aggregated sales statistics. Method:GET
Auth: rol_id = 1 (Admin only)
Response
true on success.Aggregated statistics across all returned orders:
total_ordenes(integer) — total number of ordersentregadas(integer) — orders withestado_normalizado = "entregada"pendientes(integer) — orders still inpendientestateen_proceso(integer) — orders inen_procesoorlistastatetotal_vendido(float) — sum of all order totals
Array of order objects sorted by
numero_orden descending, each containing:id_mostrado(integer) — thenumero_ordenshown in the UImesa(string) — table numberusuario_nombre(string) — full name of the waiter who placed the ordertotal(float) — order total in local currencyfecha_formateada(string) — display date/time (DD/MM/YYYY hh:mm AM/PM), derived fromfecha_entrega→fecha_lista→fecha_creacionnotas(string) — order notes, or"Sin notas"if emptyitems_detalle(array) — each line item withnombre,cantidad,precio_unitario,subtotal,estado_item,areaestado_normalizado(string) — calculated from all item states:pendiente,en_proceso,lista, orentregadaestado_subordenes(object) — separatecocinaandbaristastatus strings using the same normalization logic
| Item states | estado_normalizado |
|---|---|
All items entregado | entregada |
All items listo or entregado | lista |
At least one item en_preparacion | en_proceso |
| Everything else | pendiente |
Example
POST /public/api/adminCambiarEstadoOrden.php
Admin-only override that forces all items in a given preparation area of an order to a specific status. Useful for correcting stuck orders or testing the UI without waiting for kitchen actions. Method:POST
Auth: rol_id = 1 (Admin only)
Content-Type: application/x-www-form-urlencoded
Request Parameters
The order number (
numero_orden) to update.The target order status. Must be one of the values in the first column of the
mapping table below.
The preparation area whose items will be updated:
"cocina" or "barista".
Items in the other area are not affected.estado → detalle_orden.estado_item):
estado (request) | estado_item (stored) |
|---|---|
pendiente | pendiente |
en_proceso | en_preparacion |
lista | listo |
entregada | entregado |
Response
"OK" when the update was committed successfully.| HTTP Status | Condition |
|---|---|
400 Bad Request | numero, estado, or area is missing |
400 Bad Request | estado is not one of the four valid values |
400 Bad Request | area is not "cocina" or "barista" |
405 Method Not Allowed | Request method is not POST |
500 Internal Server Error | Database error (transaction rolled back) |