The Orders API is the core of Ordervista’s order lifecycle management. It exposes two distinct access paths: customers (role 3) can browse their own order history, view individual order details, and place new online orders (delivery or takeaway); administrators (role 1) and operators (role 2) access a separateDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ytabeloved/ordervista/llms.txt
Use this file to discover all available pages before exploring further.
/manage subtree to view all orders across the system, drill into any order’s full detail, update statuses, and register in-person orders at the counter. All routes require a valid JWT passed in the Authorization header.
GET /api/orders
Returns the complete order history for the authenticated customer. Results are scoped to the current user — customers cannot see other users’ orders. Auth required: Yes — role3 (Customer)
Response
Array of order rows joined with address and item-count information.Unique order identifier.
Order type:
1 = Delivery, 2 = Retiro, 3 = Consumo Local.Delivery address ID.
null for takeaway and in-person orders.Current status:
1 = Pendiente, 2 = En preparación, 3 = Listo, 4 = Entregado.ISO 8601 datetime the order was placed.
Order total as a decimal value (e.g.
17000.00).Optional customer note attached to the order.
Street address from the linked
DIRECCIONES row. null when no delivery address is attached.Municipality from the linked
DIRECCIONES row. null when no delivery address is attached.City from the linked
DIRECCIONES row. null when no delivery address is attached.Count of distinct line items in the order.
Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
500 | "Error al obtener el historial de pedidos" |
GET /api/orders/:id
Returns the full detail of a single order belonging to the authenticated customer, including every line item. Returns404 if the order does not exist or belongs to a different user.
Auth required: Yes — role 3 (Customer)
Path parameters
The numeric ID of the order to retrieve.
Response
Unique order identifier.
Order type:
1 = Delivery, 2 = Retiro, 3 = Consumo Local.Delivery address ID, or
null.Current order status (
1–4).ISO 8601 datetime the order was placed.
Order total.
Optional note.
Street address from the linked delivery address row.
null when no address is attached.Municipality from the linked delivery address row.
null when no address is attached.City from the linked delivery address row.
null when no address is attached.Line items for the order. Each element contains
id_detalle, id_producto, nombre, descripcion, imagen, cantidad, precio_unitario, and subtotal.Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
404 | "Pedido no encontrado" |
500 | "Error al obtener el detalle del pedido" |
POST /api/orders
Creates a new online order (delivery or takeaway) for the authenticated customer. The server validates each product’s existence, availability, and stock, then calculates all prices from the database — client-suppliedprecio_unitario, subtotal, and total values are ignored and recalculated server-side. A row is inserted into PEDIDOS, one DETALLE_PEDIDO row is created per item, stock is decremented, and a COMANDAS record is generated automatically.
Auth required: Yes — role 3 (Customer)
Request body
Order type:
1 = Delivery, 2 = Retiro.ID of a saved delivery address from
DIRECCIONES. Required when id_tipo_pedido is 1 (Delivery).Optional free-text note for the kitchen or delivery driver (max 255 characters).
Array of one or more order line items. Each object must include:
id_producto(integer, required) — product ID fromPRODUCTOScantidad(integer, required) — quantity ordered (must be greater than 0 and not exceed available stock)
Response
"Pedido creado correctamente"The newly created order’s ID.
Error responses
| Status | mensaje |
|---|---|
400 | "El pedido no contiene productos." — empty items array |
400 | "Cantidad de producto inválida." — zero or negative quantity |
400 | "Uno de los productos del pedido no existe." — unknown product ID |
400 | "El producto \"…\" no está disponible." — inactive product |
400 | "El producto \"…\" no tiene stock disponible." — zero stock |
400 | "Stock insuficiente para \"…\"." — requested quantity exceeds stock |
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
500 | "Error al crear el pedido" |
GET /api/orders/manage
Returns all orders in the system regardless of which customer placed them. Used by the operator dashboard to monitor and act on incoming orders. Auth required: Yes — role1 (Admin) or 2 (Operator)
Response
Array ofPEDIDOS rows joined with customer, address, and summarised item information.
Unique order identifier.
ID of the customer who placed the order.
Full name of the customer from
USUARIOS.nombre.Email address of the customer from
USUARIOS.email.Order type:
1 = Delivery, 2 = Retiro, 3 = Consumo Local.Delivery address ID, or
null.Current status code (
1–4).ISO 8601 datetime the order was placed.
Order total.
Optional note.
Street address from the linked delivery address row.
null when no address is attached.Municipality from the linked delivery address row.
null when no address is attached.City from the linked delivery address row.
null when no address is attached.Count of distinct line items in the order.
Pipe-separated summary of all line items (e.g.
"2x Hamburguesa Clásica||1x Papas Fritas").Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
500 | "Error al obtener la gestión de pedidos" |
GET /api/orders/manage/:id
Returns the full detail of any single order by ID, including its line items. Available to admins and operators regardless of which customer owns the order. Auth required: Yes — role1 (Admin) or 2 (Operator)
Path parameters
The numeric ID of the order to retrieve.
Response
Unique order identifier.
Customer who placed the order.
Full name of the customer from
USUARIOS.nombre.Email address of the customer from
USUARIOS.email.Order type (
1–3).Delivery address ID, or
null.Current status code (
1–4).ISO 8601 order timestamp.
Order total.
Optional note.
Street address from the linked delivery address row.
null when no address is attached.Municipality from the linked delivery address row.
null when no address is attached.City from the linked delivery address row.
null when no address is attached.Array of
DETALLE_PEDIDO rows joined with product data: id_detalle, id_producto, nombre, descripcion, imagen, cantidad, precio_unitario, subtotal.Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
404 | "Pedido no encontrado" |
500 | "Error al obtener el detalle del pedido" |
PATCH /api/orders/manage/:id/status
Updates the status of an existing order. Theid_estado value must be one of the recognised status codes. Supplying an out-of-range or missing value returns a 400 immediately without touching the database.
Auth required: Yes — role 1 (Admin) or 2 (Operator)
Path parameters
The numeric ID of the order whose status should be updated.
Request body
New status code. Accepted values:
| Value | Name |
|---|---|
1 | Pendiente |
2 | En preparación |
3 | Listo |
4 | Entregado |
Response
"Estado del pedido actualizado correctamente"Error responses
| Status | mensaje |
|---|---|
400 | "Estado de pedido inválido" — value absent or outside 1–5 |
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
404 | "Pedido no encontrado" |
500 | "Error al actualizar el estado del pedido" |
POST /api/orders/in-person
Creates a presencial (in-person / at-counter) order. Theid_tipo_pedido is automatically fixed to 3 (Consumo Local) by the server — callers must not supply it. id_direccion is always null. If observacion is omitted the server defaults it to "Pedido presencial". The same stock validation and price recalculation logic used by POST /api/orders applies here.
Auth required: Yes — role 1 (Admin) or 2 (Operator)
Request body
Optional kitchen note. Defaults to
"Pedido presencial" if not supplied.Array of line items, each containing:
id_producto(integer, required)cantidad(integer, required)
Response
"Pedido presencial creado correctamente"The newly created order’s ID.
Error responses
| Status | mensaje |
|---|---|
400 | "El pedido no contiene productos." — empty items array |
400 | "Cantidad de producto inválida." — zero or negative quantity |
400 | "Uno de los productos del pedido no existe." — unknown product ID |
400 | "El producto \"…\" no está disponible." — inactive product |
400 | "El producto \"…\" no tiene stock disponible." — zero stock |
400 | "Stock insuficiente para \"…\"." — requested quantity exceeds stock |
401 | Unauthorized — missing or invalid token |
403 | Forbidden — insufficient role |
500 | "Error al crear el pedido presencial" |