Authentication
This endpoint requires JWT authentication.
Your API key for authentication
Bearer token for user authentication. Format: Bearer {token}
Request Body
The unique identifier of the cart item to remove. This is the cart_id returned from the GET /api/cart endpoint.
Response
Indicates if the request was successful
Response message confirming the removal or indicating an error
Example Request
curl -X DELETE https://api.example.com/api/cart \
-H "x-api-key: your_api_key" \
-H "Authorization: Bearer your_jwt_token" \
-H "Content-Type: application/json" \
-d '{
"cartId": 1
}'
Example Response
{
"success": true,
"message": "Product removed from cart successfully"
}
Behavior Notes
The endpoint verifies that the cart item belongs to the authenticated user before deletion. You cannot delete items from another user’s cart.
Make sure to use the correct cart_id value from the GET /api/cart response. Using an invalid or non-existent cart ID will return a 404 error.
Error Codes
| Status Code | Description |
|---|
| 200 | Cart item removed successfully |
| 401 | Missing or invalid authentication credentials |
| 404 | Cart item not found or doesn’t belong to the user |
| 500 | Internal server error |