Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/15aozzz/Lab-Nova-Salud/llms.txt

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

The product endpoints cover the full product management lifecycle. The search and catalog endpoints power the register screen and the Productos management page; the create and update endpoints allow staff to maintain the pharmacy’s inventory.
All routes require a valid JWT in the Authorization: Bearer <token> header.

GET /api/productos

Returns the full product catalog. Each product includes all configured pricing tiers. Calls sp_get_todos_productos and groups the flat result rows by id_producto.

Query parameters

No parameters required.

Response

200 OK — returns an array of products, each with a precios array. The response shape is identical to GET /api/productos/buscar — see below for the full field reference.

Example

curl --request GET \
  --url http://localhost:3000/api/productos \
  --header 'Authorization: Bearer <token>'

GET /api/productos/buscar

Searches active products by commercial name or active ingredient. Calls sp_buscar_productos and groups the flat result rows by id_producto, attaching each pricing tier to a precios array on the parent product.

Query parameters

q
string
required
Search term matched against product name and active ingredient. Must be at least 2 characters.

Response

200 OK — returns an array of matching products, each with a precios array.
id_producto
number
Internal product ID.
nombre_comercial
string
Commercial product name (e.g., "Paracetamol 500mg").
principio_activo
string
Active ingredient (e.g., "Paracetamol").
stock_actual_unidades
number
Current stock expressed in base units.
nombre_presentacion
string
Pharmaceutical form (e.g., "TABLETA", "JARABE").
nombre_laboratorio
string
Manufacturer or laboratory name.
precios
object[]
Available price tiers for this product.

Errors

StatusConditionBody
400q missing or shorter than 2 characters{ "error": "El parámetro \"q\" debe tener al menos 2 caracteres" }
500Database or server error{ "error": "<message>" }

Example

curl --request GET \
  --url 'http://localhost:3000/api/productos/buscar?q=paracetamol' \
  --header 'Authorization: Bearer <token>'
Response
[
  {
    "id_producto": 1,
    "nombre_comercial": "Paracetamol 500mg",
    "principio_activo": "Paracetamol",
    "stock_actual_unidades": 500,
    "nombre_presentacion": "TABLETA",
    "nombre_laboratorio": "Laboratorio Génesis",
    "precios": [
      {
        "id_producto_precio": 1,
        "nombre_unidad": "UNIDAD",
        "cantidad_equivalente": 1,
        "precio_venta": 0.50
      },
      {
        "id_producto_precio": 2,
        "nombre_unidad": "BLISTER x10",
        "cantidad_equivalente": 10,
        "precio_venta": 4.50
      }
    ]
  }
]

GET /api/productos/:id/precios

Returns all available price tiers for a specific product. Calls sp_get_precios_producto. Useful when you already know the product ID and only need to refresh its pricing.

Path parameters

id
number
required
Internal product ID.

Response

200 OK — returns a flat array of price tier records for the given product.
id_producto_precio
number
Price tier ID.
nombre_unidad
string
Unit label (e.g., "UNIDAD", "BLISTER x10").
cantidad_equivalente
number
Number of base units this tier represents.
precio_venta
number
Selling price for this tier.

Errors

StatusConditionBody
500Database or server error{ "error": "<message>" }
If the product ID does not exist, the SP returns an empty array ([]) with status 200 rather than a 404. Check the array length before use.

Example

curl --request GET \
  --url http://localhost:3000/api/productos/1/precios \
  --header 'Authorization: Bearer <token>'
Response
[
  {
    "id_producto_precio": 1,
    "nombre_unidad": "UNIDAD",
    "cantidad_equivalente": 1,
    "precio_venta": 0.50
  },
  {
    "id_producto_precio": 2,
    "nombre_unidad": "BLISTER x10",
    "cantidad_equivalente": 10,
    "precio_venta": 4.50
  }
]

POST /api/productos

Creates a new product and its pricing tiers in a single transaction. Calls sp_crear_producto to create the product, then sp_agregar_precio_producto for each pricing tier.

Request body

nombre_comercial
string
required
Commercial brand name of the medicine (e.g., "Paracetamol 500mg").
laboratorio
string
required
Manufacturer or laboratory ID. Must reference an existing laboratory in the database.
categoria
string
required
Therapeutic category ID. Must reference an existing category.
precios
object[]
required
At least one pricing tier. Cannot be empty.
principio_activo
string
Active ingredient (e.g., "Paracetamol"). Optional.
presentacion
string
Pharmaceutical form ID (e.g., tablet, syrup). Optional.
stock_inicial
number
default:"0"
Starting stock in base units.
stock_minimo
number
default:"0"
Minimum stock threshold. Products below this level appear in dashboard alerts.

Response

201 Created
id_producto
number
Internal ID of the newly created product.
message
string
Confirmation message ("Producto creado exitosamente").

Errors

StatusConditionBody
400nombre_comercial, laboratorio, categoria, or precios missing{ "error": "Faltan campos obligatorios" }
500Database error or transaction rollback{ "error": "<message>" }

Example

curl --request POST \
  --url http://localhost:3000/api/productos \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "nombre_comercial": "Ibuprofeno 400mg",
    "principio_activo": "Ibuprofeno",
    "laboratorio": 1,
    "categoria": 2,
    "presentacion": 1,
    "stock_inicial": 200,
    "stock_minimo": 20,
    "precios": [
      { "nombre_unidad": "UNIDAD", "factor": 1, "precio_venta": 0.80 },
      { "nombre_unidad": "BLISTER x10", "factor": 10, "precio_venta": 7.50 }
    ]
  }'
Response
{
  "id_producto": 15,
  "message": "Producto creado exitosamente"
}

PUT /api/productos/:id

Updates a product and replaces its pricing tiers atomically. Calls sp_actualizar_producto_completo with a JSON-serialized pricing array.

Path parameters

id
number
required
Internal product ID.

Request body

nombre_comercial
string
required
Updated commercial name.
categoria
string
required
Updated category ID.
principio_activo
string
Updated active ingredient. Optional.
laboratorio
string
Updated laboratory ID. Optional.
presentacion
string
Updated presentation/form ID. Optional.
stock_actual
number
Updated current stock in base units. Optional.
stock_minimo
number
Updated minimum stock threshold. Optional.
precios
object[]
Replacement pricing tiers. Replaces all existing tiers for this product. Optional — pass an empty array to remove all tiers.

Response

200 OK
message
string
Confirmation or SP message (e.g., "Producto actualizado exitosamente").

Errors

StatusConditionBody
400nombre_comercial or categoria missing{ "error": "Faltan campos obligatorios" }
500Database error{ "error": "<message>" }

Example

curl --request PUT \
  --url http://localhost:3000/api/productos/15 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "nombre_comercial": "Ibuprofeno 400mg",
    "categoria": 2,
    "stock_minimo": 30,
    "precios": [
      { "nombre_unidad": "UNIDAD", "factor": 1, "precio_venta": 0.90 }
    ]
  }'
Response
{
  "message": "Producto actualizado exitosamente"
}

Build docs developers (and LLMs) love