Skip to main content
DELETE
/
products
/
:id
Delete Product
curl --request DELETE \
  --url https://api.example.com/products/:id
{
  "error": true,
  "msg": "<string>",
  "salesList": [
    {
      "idSaleDetails": "<string>",
      "idSale": "<string>"
    }
  ]
}
This endpoint deletes a product identified by its UUID. The deletion will fail if there are existing sales that reference this product due to foreign key constraints.

Path Parameters

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

Response

error
boolean
Indicates if an error occurred during the request
msg
string
Response message describing the result

Success Response Example (200)

{
  "error": false,
  "msg": "Product deleted successfully"
}

Error Responses

400 - Invalid UUID

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

409 - Foreign Key Constraint Violation

A product cannot be deleted if it is referenced in any sales. You must delete or update the related sales first.
When attempting to delete a product that has associated sales, the API returns a list of all sales (sale details and sale IDs) that reference this product:
{
  "error": true,
  "msg": "there are sales with this product",
  "salesList": [
    {
      "idSaleDetails": "4033e9a1-5858-44c9-b1d7-39c718933372",
      "idSale": "878d89a7-a1a1-4411-a359-1ad08965fb30"
    }
  ]
}
salesList
array
Array of sales that reference this product (only present when deletion fails)

Database Constraints

The product has foreign key relationships with:
  • Sales Details: Products referenced in sales cannot be deleted
  • Categories: Products must belong to a valid category
Before deleting a product, ensure:
  1. No sales contain this product, or
  2. Remove the product from all sales first, or
  3. Delete the sales that contain this product

Build docs developers (and LLMs) love