Skip to main content
POST
/
secured
/
add_producto
curl --location 'http://localhost:8080/secured/add_producto' \
--header 'Authorization: YOUR_JWT_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
  "clave": "PROD001",
  "linea": "Electronics",
  "descripcion": "High-quality electronic component",
  "precio": 150.50,
  "existencias": 45,
  "unidad": "PCS",
  "typeWoo": "simple",
  "shortDescription": "Compact design",
  "descriptionWOO": "Full detailed description",
  "categoryWOO": "Components"
}'
{
  "msg": "Producto añadido correctamente"
}
This endpoint allows you to add a new product to the productossae table. It validates that the product key (clave) is unique before inserting.

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header (raw token, no “Bearer” prefix).
Authorization
string
required
JWT token for authentication (raw token without Bearer prefix)

Request Body

clave
string
required
Unique product key/identifier. Must not already exist in the database.
linea
string
Product line
descripcion
string
Product description
precio
number
Product price
existencias
number
Stock quantity
unidad
string
Unit of entry/measurement
typeWoo
string
WooCommerce product type (e.g., “simple”, “variable”)
shortDescription
string
Short description for WooCommerce
descriptionWOO
string
Full description for WooCommerce
categoryWOO
string
WooCommerce category name

Response

msg
string
Success or error message
  • Success: “Producto añadido correctamente”
  • Error: “ERROR: La clave de producto ya esta registrada.” (duplicate key)
  • Error: “ERROR: Revise los campos.” (empty clave)
  • Error: “ERROR: Algo fue mal, intentelo mas tarde” (database error)
curl --location 'http://localhost:8080/secured/add_producto' \
--header 'Authorization: YOUR_JWT_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
  "clave": "PROD001",
  "linea": "Electronics",
  "descripcion": "High-quality electronic component",
  "precio": 150.50,
  "existencias": 45,
  "unidad": "PCS",
  "typeWoo": "simple",
  "shortDescription": "Compact design",
  "descriptionWOO": "Full detailed description",
  "categoryWOO": "Components"
}'
{
  "msg": "Producto añadido correctamente"
}

Error Codes

200
success
Product added successfully
400
error
Bad Request - Duplicate product key, empty clave field, or validation error
401
error
Unauthorized - Invalid or missing authentication token

Implementation Notes

  • The clave field is checked for uniqueness before insertion (lines 223-227 in cliente.js:223)
  • If the clave already exists, a 400 error is returned
  • Empty clave values are rejected with a validation error

Build docs developers (and LLMs) love