Skip to main content

Overview

The Products API provides endpoints for creating, updating, searching, and deleting product records. All endpoints require authentication via session.

Create Product

curl -X POST https://your-domain.com/ajax/nuevo_producto.php \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: PHPSESSID=your-session-id" \
  -d "codigo=PROD-001" \
  -d "nombre=Premium Widget" \
  -d "precio=99.99" \
  -d "estado=1"
codigo
string
required
Product code (up to 20 characters, must be unique)
nombre
string
required
Product name (up to 255 characters)
precio
float
required
Product price (sale price)
estado
integer
required
Product status: 1 for active, 0 for inactive
success
html
Returns HTML alert with success message: “Producto ha sido ingresado satisfactoriamente.”
error
html
Returns HTML alert with error message if validation fails

Update Product

curl -X POST https://your-domain.com/ajax/editar_producto.php \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Cookie: PHPSESSID=your-session-id" \
  -d "mod_id=5" \
  -d "mod_codigo=PROD-001" \
  -d "mod_nombre=Premium Widget Pro" \
  -d "mod_precio=129.99" \
  -d "mod_estado=1"
mod_id
integer
required
Product ID to update
mod_codigo
string
required
Updated product code
mod_nombre
string
required
Updated product name
mod_precio
float
required
Updated product price
mod_estado
integer
required
Updated status: 1 for active, 0 for inactive
success
html
Returns HTML alert with message: “Producto ha sido actualizado satisfactoriamente.”
error
html
Returns HTML alert with error message if validation fails

Search Products

curl -X GET "https://your-domain.com/ajax/buscar_productos.php?action=ajax&q=widget&page=1" \
  -H "Cookie: PHPSESSID=your-session-id"
action
string
required
Must be set to "ajax" to trigger search
q
string
Search term to filter products by code or name. Leave empty to return all products.
page
integer
Page number for pagination (default: 1, 10 results per page)
html_table
html
Returns HTML table with product data including:
  • id_producto - Product ID
  • codigo_producto - Product code
  • nombre_producto - Product name
  • status_producto - Status (1 = Active, 0 = Inactive)
  • precio_producto - Product price
  • date_added - Date added (formatted as d/m/Y)

Delete Product

curl -X GET "https://your-domain.com/ajax/buscar_productos.php?id=5" \
  -H "Cookie: PHPSESSID=your-session-id"
id
integer
required
Product ID to delete
success
html
Returns success alert if product is deleted successfully
error
html
Returns error alert if:
  • Product has associated invoice line items (foreign key constraint)
  • Database error occurs
Products cannot be deleted if they are referenced in any invoice line items (detalle_factura table).

Search Products for Invoice

curl -X GET "https://your-domain.com/ajax/productos_factura.php?action=ajax&q=widget&page=1" \
  -H "Cookie: PHPSESSID=your-session-id"
action
string
required
Must be set to "ajax" to trigger search
q
string
Search term to filter products by code or name
page
integer
Page number for pagination (default: 1, 5 results per page)
html_table
html
Returns HTML table with simplified product data for invoice creation:
  • Product code
  • Product name
  • Quantity input field (default: 1)
  • Price input field (editable)
  • Add button to add product to invoice
This endpoint is specifically designed for use in the invoice creation interface. It returns 5 products per page (instead of 10) and includes interactive form elements.

Build docs developers (and LLMs) love