Skip to main content
DELETE
/
api
/
products
/
:id
Delete Product
curl --request DELETE \
  --url https://api.example.com/api/products/:id
{
  "success": true
}

Endpoint

DELETE /api/products/:id

Authentication

Admin access required. Only users with the ADMIN role can delete products.

Path Parameters

id
number
required
The unique identifier of the product to delete

Request Headers

Authorization: Bearer <access_token>

Response

success
boolean
Indicates if the product was deleted successfully

Example Request

curl -X DELETE "https://api.pcfix.com/api/products/42" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

{
  "success": true
}

Error Responses

Invalid Product ID

{
  "success": false,
  "error": "Product not found"
}

Unauthorized

{
  "success": false,
  "error": "Unauthorized - Admin access required"
}

Product Has Dependencies

{
  "success": false,
  "error": "Cannot delete product with existing orders or cart items"
}

Server Error

{
  "success": false,
  "error": "Error message description"
}

Notes

  • This operation implements soft delete - the product is marked with a deletedAt timestamp rather than being permanently removed
  • Soft-deleted products are excluded from product listings by default
  • Products that are referenced in existing orders cannot be permanently deleted to maintain data integrity
  • Consider setting stock to 0 and removing from featured status before deletion
  • Related cart items and favorites may be affected by product deletion

Build docs developers (and LLMs) love