Skip to main content
DELETE
/
orders
/
{id}
curl -X DELETE http://localhost:3000/orders/65abc123def456789012345 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
{
  "message": "🗑️ Orden eliminada",
  "order": {
    "_id": "65abc123def456789012345",
    "products": [
      {
        "product": {
          "_id": "507f1f77bcf86cd799439011",
          "name": "Gaming Mouse",
          "price": 49.99,
          "brand": "Logitech"
        },
        "quantity": 2,
        "customName": "Special Edition Mouse"
      }
    ],
    "total": 99.98,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  }
}
Deletes an order by its ID. This operation does not restore product stock.

Authentication

This endpoint requires authentication. Include a valid JWT token in the Authorization header.

Path Parameters

id
string
required
The MongoDB ObjectId of the order to delete

Response

message
string
Success message confirming order deletion
order
object
The deleted order object
_id
string
Unique order identifier
products
array
Array of ordered products
product
object
Product details (populated with name, price, brand)
quantity
number
Quantity ordered
customName
string
Custom product name if provided
total
number
Total price of the order
createdAt
string
Timestamp when order was created
updatedAt
string
Timestamp when order was last updated
Deleting an order does NOT restore the product stock. The quantities that were deducted during order creation remain deducted after deletion.

Error Responses

  • 401 Unauthorized: Missing or invalid authentication token
  • 404 Not Found: Order with specified ID does not exist
  • 500 Internal Server Error: Server error during deletion
curl -X DELETE http://localhost:3000/orders/65abc123def456789012345 \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
{
  "message": "🗑️ Orden eliminada",
  "order": {
    "_id": "65abc123def456789012345",
    "products": [
      {
        "product": {
          "_id": "507f1f77bcf86cd799439011",
          "name": "Gaming Mouse",
          "price": 49.99,
          "brand": "Logitech"
        },
        "quantity": 2,
        "customName": "Special Edition Mouse"
      }
    ],
    "total": 99.98,
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z"
  }
}

Build docs developers (and LLMs) love