Skip to main content
PATCH
/
products
/
:id
Update Product
curl --request PATCH \
  --url https://api.example.com/products/:id \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "description": "<string>",
  "stock": 123,
  "price": 123,
  "categoriesID": 123
}
'
{
  "error": true,
  "msg": "<string>"
}
This endpoint updates a product identified by its UUID. All fields are optional - you only need to include the fields you want to update.

Path Parameters

id
string
required
Product UUID identifierValidation: Must be a valid UUID format

Request Body

All fields are optional. Include only the fields you want to update.
name
string
Product name. Must be at least 3 characters long if provided.Validation: Minimum length of 3 characters
description
string
Product description. Must be between 3 and 3000 characters if provided.Validation: Minimum 3 characters, maximum 3000 characters
stock
integer
Available stock quantity. Must be a non-negative integer if provided.Validation: Integer, minimum value of 0
price
integer
Product price. Must be a non-negative integer if provided.Validation: Integer, minimum value of 0
categoriesID
integer
Category ID. Must reference an existing category if provided.Validation: Integer, minimum value of 0

Request Example

{
  "name": "Coca cola",
  "description": "Bebida gasificada de 2ltr",
  "stock": 40,
  "price": 3000,
  "categoriesID": 1
}
Or update just specific fields:
{
  "stock": 50,
  "price": 3200
}

Response

error
boolean
Indicates if an error occurred during the request
msg
string
Response message (“product modify sucessfully” on success)

Success Response Example (200)

{
  "error": false,
  "msg": "product modify sucessfully"
}

Error Responses

400 - Invalid UUID

{
  "error": true,
  "msg": "the id is invalid"
}

400 - Empty Body

{
  "error": true,
  "msg": "request body is empty"
}

400 - Invalid Data Format

{
  "error": true,
  "msg": "the data format is invalid"
}

409 - Conflict

Returned when the product is not found or a database constraint is violated.
{
  "error": true,
  "msg": "Error message describing the issue"
}

Validation Rules

Fields are validated using “soft” validation (validateProductSoft) which only validates fields that are provided:
  • name: String with minimum 3 characters (if provided)
  • description: String with minimum 3 characters and maximum 3000 characters (if provided)
  • price: Integer with minimum value 0 (if provided)
  • stock: Integer with minimum value 0 (if provided)
  • categoriesID: Integer with minimum value 0 (if provided, must reference existing category)

Build docs developers (and LLMs) love