Delete Cart
Completely removes an existing cart from the system.
HTTP Method & Endpoint
DELETE | /cart/{cartId}
Request
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cartId | String | Yes | Unique identifier of the cart to delete |
Headers
| Header | Value | Description |
|---|---|---|
Authorization | Bearer {token} | Authentication token (replace {token} with your actual token) |
x-store-id | {storeId} | StoreId (replace {storeId} with your actual storeId) |
Response Format
Success Response (200 OK)
| Field | Type | Description |
|---|---|---|
message | String | Status message indicating the result of the operation |
data | Object | Empty object |
source | String | Source of the operation (e.g., "db") |
Examples
cURL
curl -X DELETE "https://dev-sfapi.unisouk.com/cart/33863324215067648" \
-H "Authorization: Bearer <TOKEN>" \
-H "x-store-id: <STORE_ID>"
JavaScript (React)
import axios from "axios";
const deleteCart = async (cartId) => {
try {
const response = await axios.delete(`https://dev-sfapi.unisouk.com/cart/${cartId}`, {
headers: {
Authorization: "Bearer <TOKEN>",
"x-store-id": "<STORE_ID>",
},
});
console.log("Cart deleted successfully:", response.data);
} catch (error) {
console.error("Error deleting cart:", error.response?.data || error.message);
}
};
// Example usage
deleteCart("cart_PhIidALwQ8JFCBOU");
Sample Response
{
"message": "Cart Deleted Successfully",
"data": {},
"source": "db"
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid cart ID format |
| 401 | Unauthorized - Authentication token is missing or invalid |
| 403 | Forbidden - User does not have permission to delete this cart |
| 404 | Not Found - Cart with the specified ID was not found |
| 500 | Internal Server Error - Something went wrong on the server |
Notes
- This operation permanently deletes the cart and all its items. This action cannot be undone.
- If you want to empty a cart but keep the cart itself, consider using the Remove Item endpoint for all items instead.