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

Overview

This endpoint allows administrators to permanently delete a product from the catalog. This action cannot be undone.

Endpoint

DELETE /products/:id

Path Parameters

id
integer
required
The unique identifier of the product to delete

Authentication

Required: Admin role This endpoint requires a valid JWT token with admin privileges. Include the token in the Authorization header:
Authorization: Bearer <your_token>

Response

Returns no content on successful deletion. Status Code: 204 No Content

Example Request

curl -X DELETE https://api.example.com/products/1 \
  -H "Authorization: Bearer <your_admin_token>"

Example Response

No response body. HTTP status code 204 No Content indicates successful deletion.

Error Responses

Product Not Found

{
  "error": "Product not found"
}
Status Code: 404 Not Found

Unauthorized

{
  "error": "Unauthorized"
}
Status Code: 401 Unauthorized

Forbidden (Non-Admin User)

{
  "error": "Admin access required"
}
Status Code: 403 Forbidden

Conflict (Product in Orders)

If the product has associated order items, deletion may be restricted based on the database constraints:
{
  "error": "Cannot delete product with existing orders"
}
Status Code: 409 Conflict

Important Notes

  • This action is permanent and cannot be undone
  • Due to the Prisma schema’s onDelete: Restrict constraint on OrderItem relations, products that are referenced in existing orders cannot be deleted
  • CartItem relations use onDelete: Cascade, so deleting a product will automatically remove it from all carts
  • Only administrators can perform this action

Build docs developers (and LLMs) love