Skip to main content
POST
/
api
/
Producto
/
Guardar
Create Product
curl --request POST \
  --url https://api.example.com/api/Producto/Guardar \
  --header 'Content-Type: application/json' \
  --data '
{
  "nombre": "<string>",
  "idCategoria": 123,
  "stock": 123,
  "precio": "<string>",
  "esActivo": 123,
  "idProducto": 123,
  "descripcionCategoria": "<string>"
}
'
{
  "status": true,
  "value": {
    "idProducto": 123,
    "nombre": "<string>",
    "idCategoria": 123,
    "descripcionCategoria": "<string>",
    "stock": 123,
    "precio": "<string>",
    "esActivo": 123
  },
  "msg": "<string>"
}

Endpoint

POST /api/Producto/Guardar
Creates a new product with the provided information. The product will be assigned a unique ID upon creation.

Request Body

nombre
string
required
Product name
idCategoria
integer
required
ID of the category this product belongs to
stock
integer
required
Initial stock quantity
precio
string
required
Product price (formatted as string, e.g., “99.99”)
esActivo
integer
default:"1"
Active status (1 = active, 0 = inactive)
idProducto
integer
Leave empty or 0 for new products (auto-generated)
descripcionCategoria
string
Read-only field, automatically populated from category

Response

The response is wrapped in a Response<T> object containing the created product.
status
boolean
required
Indicates whether the product was created successfully
value
object
required
The created product object with all fields populated
msg
string
Error message (only populated when status is false)

Example Request

curl -X POST "http://localhost:5000/api/Producto/Guardar" \
  -H "Content-Type: application/json" \
  -d '{
    "nombre": "Monitor Samsung 27",
    "idCategoria": 1,
    "stock": 25,
    "precio": "349.99",
    "esActivo": 1
  }'

Example Response

{
  "status": true,
  "value": {
    "idProducto": 15,
    "nombre": "Monitor Samsung 27",
    "idCategoria": 1,
    "descripcionCategoria": "Electrónica",
    "stock": 25,
    "precio": "349.99",
    "esActivo": 1
  },
  "msg": null
}

Response Status

This endpoint always returns HTTP 200. Check the status field in the response body to determine success or failure.
  • status: true - Product created successfully
  • status: false - An error occurred (check msg field for details)

Validation

  • Product name must not be empty
  • Category ID must reference an existing category
  • Stock must be a non-negative integer
  • Price must be a valid decimal number formatted as a string

Build docs developers (and LLMs) love