Skip to main content

Overview

The Products API allows you to manage your product catalog, including simple products and products with variants. The system automatically generates SKUs and EAN-13 barcodes when not provided.

Auto-Generation Features

  • SKU Generation: Automatically generates SKUs in format PROD-00001, PROD-00002, etc.
  • EAN-13 Barcode: Generates valid EAN-13 barcodes using the GS1 prefix 200 (reserved for internal use)

Create Product

Creates a new product in the catalog. SKU and barcode are auto-generated if not provided.

Request Body

nombre
string
required
Product name
codigo_interno
string
Internal SKU code. If not provided, auto-generates in format PROD-00001
descripcion
string
Product description
precio_neto
decimal
required
Net price (before tax)
unidad_medida
string
default:"unidad"
Unit of measure (e.g., “unidad”, “kg”, “lt”)
codigo_barras
string
Barcode (EAN-13/UPC). Auto-generated if not provided
controla_stock
boolean
default:false
Whether to track inventory for this product
stock_actual
decimal
default:0
Current stock level
stock_minimo
decimal
default:0
Minimum stock threshold for reorder alerts
brand_id
integer
Brand ID to associate with this product
tax_id
integer
Tax ID to apply to this product
parent_id
integer
Parent product ID (for variants)

Response

id
integer
Unique product identifier
codigo_interno
string
Internal SKU code
nombre
string
Product name
descripcion
string
Product description
precio_neto
decimal
Net price (before tax)
precio_bruto
decimal
Gross price (including tax)
costo_unitario
decimal
Unit cost for margin calculation
codigo_barras
string
Product barcode
controla_stock
boolean
Whether inventory is tracked
stock_actual
decimal
Current stock level
stock_minimo
decimal
Minimum stock threshold
is_active
boolean
Whether the product is active
brand
object
Associated brand information
tax
object
Associated tax information
variants
array
Child product variants

Example

curl -X POST "https://api.example.com/products/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Laptop Dell XPS 15",
    "descripcion": "15-inch professional laptop",
    "precio_neto": 999990,
    "unidad_medida": "unidad",
    "controla_stock": true,
    "stock_actual": 10,
    "stock_minimo": 3,
    "brand_id": 1,
    "tax_id": 1
  }'

Create Product with Variants

Creates a parent product and its variants in a single request. Useful for products with multiple sizes, colors, or configurations.

Request Body

nombre
string
required
Parent product name
codigo_interno
string
Parent SKU. Auto-generated if not provided
descripcion
string
Parent product description
precio_neto
decimal
default:0
Base price for the parent (typically 0 for variant-only products)
controla_stock
boolean
default:false
Whether variants should track inventory
stock_minimo
decimal
default:0
Minimum stock threshold for variants
brand_id
integer
Brand ID for the product family
tax_id
integer
Tax ID to apply to all variants
variants
array
required
Array of variant objects
variants[].nombre
string
required
Variant name (e.g., “Talla 42”, “Rojo XL”)
variants[].precio_neto
decimal
required
Variant price
variants[].codigo_interno
string
Variant SKU. Auto-generated as {parent_sku}-V01, {parent_sku}-V02, etc.
variants[].codigo_barras
string
Variant barcode. Auto-generated if not provided
variants[].stock_actual
decimal
default:0
Current stock for this variant

Example

curl -X POST "https://api.example.com/products/with-variants" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Zapatillas Running Pro",
    "descripcion": "Professional running shoes",
    "controla_stock": true,
    "brand_id": 2,
    "tax_id": 1,
    "variants": [
      {
        "nombre": "Talla 39",
        "precio_neto": 59990,
        "stock_actual": 5
      },
      {
        "nombre": "Talla 40",
        "precio_neto": 59990,
        "stock_actual": 8
      },
      {
        "nombre": "Talla 41",
        "precio_neto": 59990,
        "stock_actual": 6
      }
    ]
  }'

List Products

Returns all active (non-deleted) products, ordered by most recent first.

Response

Returns an array of product objects with the same structure as the Create Product response.

Example

curl -X GET "https://api.example.com/products/" \
  -H "Authorization: Bearer YOUR_TOKEN"

Get Product by SKU

Retrieves a product by its internal SKU code.

Path Parameters

codigo
string
required
The product’s internal SKU code (e.g., “PROD-00001”)

Response

Returns a single product object.

Example

curl -X GET "https://api.example.com/products/PROD-00001" \
  -H "Authorization: Bearer YOUR_TOKEN"

Update Product

Updates an existing product. All fields are optional (partial update).

Path Parameters

product_id
integer
required
The product ID to update

Request Body

All fields from the Create Product endpoint are available as optional parameters.
codigo_interno
string
Internal SKU code (must be unique)
nombre
string
Product name
precio_neto
decimal
Net price
costo_unitario
decimal
Unit cost
stock_actual
decimal
Current stock level
is_active
boolean
Active status

Example

curl -X PUT "https://api.example.com/products/1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "precio_neto": 899990,
    "stock_actual": 15
  }'

Delete Product

Performs a soft delete of the product and all its variants. The product is marked as deleted and deactivated but not removed from the database.

Path Parameters

product_id
integer
required
The product ID to delete

Response

Returns 204 No Content on success.

Example

curl -X DELETE "https://api.example.com/products/1" \
  -H "Authorization: Bearer YOUR_TOKEN"

Notes

  • SKU Auto-Generation: The system uses the highest existing numeric suffix and increments it. If PROD-00005 exists, the next auto-generated SKU will be PROD-00006.
  • EAN-13 Format: Auto-generated barcodes use format 200{product_id:09d}{check_digit} with a valid check digit calculation.
  • Variants: Parent products with variants typically don’t control stock directly; stock is tracked at the variant level.
  • Soft Deletes: Deleted products remain in the database with is_deleted=true and is_active=false.

Build docs developers (and LLMs) love