La Comanda exposes a set of internal PHP API endpoints used exclusively by its own frontend views and AJAX calls. This is not a public REST API — there are no bearer tokens or API keys. Access is controlled entirely through PHP sessions established via the login form, and every protected endpoint validates that the caller holds an active, authenticated session before processing any request.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.
Authentication Model
All protected endpoints require an active PHP session. A session is established when a user logs in through theviews/login.php form; PHP sets a PHPSESSID cookie that the browser sends automatically on every subsequent request.
The
PHPSESSID cookie must be present on all API requests. If the session is
missing or expired, the server issues an HTTP redirect to views/login.php
rather than returning a 401 JSON response.| Middleware | File | What it does |
|---|---|---|
| Session guard | middleware/auth.php | Starts the session, checks $_SESSION['usuario_id'], touches the active-session timestamp via SesionesActivas::tocarSesionActual(), and redirects unauthenticated callers to the login page |
| Role guard | middleware/roles.php | Reads $_SESSION['rol_id'] and calls verificarRol(array $rolesPermitidos). Role 1 (Admin) is always allowed through; other roles must be listed explicitly |
| rol_id | Role name |
|---|---|
1 | Administrador |
2 | Mesero |
3 | Cocina |
4 | Barista |
Response Format
Every endpoint setsContent-Type: application/json; charset=UTF-8. Response bodies follow one of two conventions depending on the endpoint family:
Standard envelope (status key)
ok key)
marcarEntrega and several admin form controllers) respond with an HTTP redirect instead of JSON. These are noted explicitly in their endpoint pages.
HTTP status codes used across the API:
| Code | Meaning |
|---|---|
200 OK | Request processed successfully |
400 Bad Request | Missing or invalid request parameters |
403 Forbidden | Active session exists but role is not permitted |
405 Method Not Allowed | Wrong HTTP verb used |
500 Internal Server Error | Unhandled server-side exception |
All Endpoints
Authentication
POST
logout.php — destroy session and redirect to loginPOST forgotPassword.php — send password reset email via MailtrapOrders
POST
guardarOrden.php — create a new orderGET obtenerOrdenes.php — list kitchen ordersPOST entregarOrden.php — mark table order as deliveredPOST marcarEntrega.php — mark full order delivered (kitchen flow)GET ordenesAdminData.php — full order history with statsPOST adminCambiarEstadoOrden.php — admin force-change order statusProducts
GET
listarProductos.php — list products by category slugPOST nuevoProducto.php — create a productPOST editarProducto.php — update an existing productPOST eliminarProducto.php — soft-delete a productCategories
POST
nuevaCategoria.php — create a categoryPOST editarCategoria.php — update a categoryPOST eliminarCategoria.php — delete a categoryUsers
POST
nuevoUsuario.php — create a system userPOST editarUsuario.php — update a userPOST eliminarUsuario.php — deactivate a userGET usuariosConectados.php — list currently active sessionsTables
GET
estadoMesas.php — current order state per table for calling userGET / POST / DELETE layoutMesas.php — read or persist the visual floor-plan layoutKitchen & Barista
GET
obtenerOrdenes.php — kitchen order feed (non-barista items)POST cocinaAccion.php — advance kitchen order (preparacion / lista)POST baristaAccion.php — advance barista order (preparacion / lista)GET baristaEstado.php — barista panel (pendientes + listas)Password Reset
POST
forgotPassword.php — request a password reset link by emailRole Requirements Summary
| Endpoint | Method | Minimum Roles Required |
|---|---|---|
logout.php | POST | Any authenticated session |
forgotPassword.php | POST | None (public) |
guardarOrden.php | POST | Admin (1), Mesero (2) |
obtenerOrdenes.php | GET | Admin (1), Cocina (3) |
entregarOrden.php | POST | Admin (1), Mesero (2) |
marcarEntrega.php | POST | Admin (1), Cocina (3) |
ordenesAdminData.php | GET | Admin (1) only |
adminCambiarEstadoOrden.php | POST | Admin (1) only |
listarProductos.php | GET | Any authenticated session |
nuevoProducto.php | POST | Admin (1) only |
editarProducto.php | POST | Admin (1) only |
eliminarProducto.php | POST | Admin (1) only |
nuevaCategoria.php | POST | Admin (1) only |
editarCategoria.php | POST | Admin (1) only |
eliminarCategoria.php | POST | Admin (1) only |
nuevoUsuario.php | POST | Admin (1) only |
editarUsuario.php | POST | Admin (1) only |
eliminarUsuario.php | POST | Admin (1) only |
usuariosConectados.php | GET | Admin (1) only |
estadoMesas.php | GET | Any authenticated session |
layoutMesas.php | GET | Any authenticated session |
layoutMesas.php | POST / DELETE | Admin (1) only |
cocinaAccion.php | POST | Admin (1), Cocina (3) |
baristaAccion.php | POST | Admin (1), Barista (4) |
baristaEstado.php | GET | Admin (1), Barista (4) |