DELETE /api/v1/cart
Clear all cart items, or only items of a specific cart type.
Authentication: Required
Cache: None
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
cartType | string | No | Clear only this cart type. Omit to clear all items. |
Sample Request
# Clear all items
curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://api.grails.app/api/v1/cart \
-d '{}'
# Clear only "buy" items
curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://api.grails.app/api/v1/cart \
-d '{ "cartType": "buy" }'Response
// 200 OK — with cartType specified
{
"success": true,
"data": {
"message": "Cleared buy cart",
"deletedCount": 3
},
"meta": {
"timestamp": "2026-04-08T00:00:00.000Z",
"version": "1.0.0"
}
}When cartType is omitted, all items are cleared:
// 200 OK — all items
{
"success": true,
"data": {
"message": "Cleared all cart items",
"deletedCount": 5
},
"meta": {
"timestamp": "2026-04-08T00:00:00.000Z",
"version": "1.0.0"
}
}Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid request body |
| 400 | INVALID_CART_TYPE | Cart type does not exist |
| 401 | UNAUTHORIZED | Missing or invalid token |
| 500 | INTERNAL_ERROR | Failed to clear cart |
Last updated on