Skip to main content

Documentation 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.

The Products API provides full CRUD access to individual menu items stored in the PRODUCTOS table. All endpoints under /api/products require a valid JWT and are restricted to the Administrator role (id_rol: 1). Each product belongs to a category via id_categoria, carries a decimal precio, an integer stock count, an optional imagen URL, and an activo flag. Only active products in active categories with stock greater than zero are surfaced on the public menu via GET /api/menu.

GET /api/products

Returns all product records from the PRODUCTOS table, including inactive products and those with zero stock. Results are fetched via a JOIN with the CATEGORIAS table, so each object also includes the resolved category name. Auth required: Yes — Administrator (id_rol: 1)

Response 200 OK

An array of product objects.
id_producto
integer
Auto-incremented primary key.
nombre
string
Product name (up to 150 characters).
descripcion
string | null
Optional description of the product.
precio
number (decimal)
Unit price. Stored as DECIMAL(10,2).
stock
integer
Current available quantity. Defaults to 0.
imagen
string | null
URL to the product image (up to 255 characters), or null.
activo
boolean
Whether the product is active. Defaults to true.
id_categoria
integer
Foreign key referencing the category this product belongs to.
categoria
string
Human-readable category name resolved from the CATEGORIAS table.
curl -X GET https://api.ordervista.com/api/products \
  -H "Authorization: Bearer <token>"
[
  {
    "id_producto": 1,
    "nombre": "Hamburguesa Clásica",
    "descripcion": "Carne 200g, lechuga, tomate, cheddar",
    "precio": 8500.00,
    "stock": 50,
    "imagen": "https://example.com/hamburguesa-clasica.jpg",
    "activo": true,
    "id_categoria": 1,
    "categoria": "Hamburguesas"
  }
]

Error responses

StatusmensajeCause
401"Token no proporcionado" / "Token inválido"Missing or invalid JWT.
403"Acceso denegado"Authenticated user does not have the Administrator role.
500"Error al obtener productos"Unexpected server-side error.

GET /api/products/:id

Retrieves a single product by its primary key. Auth required: Yes — Administrator (id_rol: 1)

Path parameters

id
integer
required
The id_producto of the product to retrieve.

Response 200 OK

A single product object with the same fields as described in GET /api/products.
curl -X GET https://api.ordervista.com/api/products/1 \
  -H "Authorization: Bearer <token>"
{
  "id_producto": 1,
  "nombre": "Hamburguesa Clásica",
  "descripcion": "Carne 200g, lechuga, tomate, cheddar",
  "precio": 8500.00,
  "stock": 50,
  "imagen": "https://example.com/hamburguesa-clasica.jpg",
  "activo": true,
  "id_categoria": 1,
  "categoria": "Hamburguesas"
}

Error responses

StatusmensajeCause
401"Token no proporcionado" / "Token inválido"Missing or invalid JWT.
403"Acceso denegado"Insufficient role.
404"Producto no encontrado"No product exists with the given id.
500"Error al obtener producto"Unexpected server-side error.

POST /api/products

Creates a new menu product. nombre, precio, and id_categoria are required; all other fields are optional. Auth required: Yes — Administrator (id_rol: 1)

Request body

nombre
string
required
Product name (up to 150 characters).
precio
number
required
Unit price as a decimal number (e.g. 8500.00).
id_categoria
integer
required
Foreign key of the category to assign this product to. Must reference an existing id_categoria.
descripcion
string
Optional description of the product.
stock
integer
Initial available stock quantity. Defaults to 0 if omitted.
imagen
string
Optional URL pointing to the product image (up to 255 characters).
activo
boolean
Whether the product is active. Defaults to true if omitted.

Response 201 Created

mensaje
string
Confirmation message: "Producto creado correctamente".
id_producto
integer
The auto-generated primary key of the new product.
curl -X POST https://api.ordervista.com/api/products \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Hamburguesa Clásica",
    "descripcion": "Carne 200g, lechuga, tomate, cheddar",
    "precio": 8500.00,
    "stock": 50,
    "imagen": "https://example.com/hamburguesa-clasica.jpg",
    "id_categoria": 1
  }'
{
  "mensaje": "Producto creado correctamente",
  "id_producto": 1
}

Error responses

StatusmensajeCause
400"Nombre, precio y categoría son obligatorios"One or more of nombre, precio, or id_categoria is missing.
401"Token no proporcionado" / "Token inválido"Missing or invalid JWT.
403"Acceso denegado"Insufficient role.
500"Error al crear producto"Unexpected server-side error.

PUT /api/products/:id

Updates one or more fields on an existing product. Only the fields provided in the request body are changed. Auth required: Yes — Administrator (id_rol: 1)

Path parameters

id
integer
required
The id_producto of the product to update.

Request body

All fields are optional.
nombre
string
New product name.
descripcion
string
New description.
precio
number
New unit price.
stock
integer
New stock quantity.
imagen
string
New image URL.
id_categoria
integer
New category assignment.
activo
boolean
Set to false to deactivate the product and hide it from the menu.

Response 200 OK

mensaje
string
Confirmation message: "Producto actualizado correctamente".
curl -X PUT https://api.ordervista.com/api/products/1 \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "precio": 9200.00,
    "stock": 35
  }'
{
  "mensaje": "Producto actualizado correctamente"
}

Error responses

StatusmensajeCause
401"Token no proporcionado" / "Token inválido"Missing or invalid JWT.
403"Acceso denegado"Insufficient role.
404"Producto no encontrado"No product exists with the given id.
500"Error al actualizar producto"Unexpected server-side error.

DELETE /api/products/:id

Permanently removes a product from the system. Auth required: Yes — Administrator (id_rol: 1)

Path parameters

id
integer
required
The id_producto of the product to delete.

Response 200 OK

mensaje
string
Confirmation message: "Producto eliminado correctamente".
curl -X DELETE https://api.ordervista.com/api/products/1 \
  -H "Authorization: Bearer <token>"
{
  "mensaje": "Producto eliminado correctamente"
}

Error responses

StatusmensajeCause
401"Token no proporcionado" / "Token inválido"Missing or invalid JWT.
403"Acceso denegado"Insufficient role.
404"Producto no encontrado"No product exists with the given id.
500"Error al eliminar producto"Unexpected server-side error.

Build docs developers (and LLMs) love