Skip to main content

Version: v1

Remove Item from Cart

Remove a specific product item from an existing cart.


HTTP Method & Endpoint

DELETE | /cart/item


Request

Headers

HeaderValueDescription
Content-Typeapplication/jsonSpecifies that the request body is in JSON format
AuthorizationBearer {token}Authentication token (replace {token} with your actual token)
x-store-id{storeId}StoreId (replace {storeId} with your actual storeId)

Request Body Parameters

ParameterTypeRequiredDescription
cartIdStringYesUnique identifier of the cart containing the item
variantIdStringYesID of the product variant to remove

Response Format

Success Response (200 OK)

FieldTypeDescription
messageStringStatus message indicating the result of the operation
dataDataContains all details about the updated cart
sourceStringSource of the order data (e.g., "db")

Data Object Properties

FieldTypeDescription
idStringUnique identifier for the cart
storeIdStringStore ID for which the cart was created
customerIdStringCustomer's unique identifier
totalAmountNumberTotal amount payable for the items in the cart
itemsArray(Items)List of remaining items in the cart

Items Array Properties

FieldTypeDescription
variantIdStringID of the product variant
quantityNumberNumber of units in the cart
priceNumberPrice per unit (in paise)

Examples

cURL

curl -X DELETE "https://dev-sfapi.unisouk.com/cart/item" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
-H "x-store-id: <STORE_ID>" \
-d '{
"cartId": "cart_6oFGyknVpz8ltKuw",
"variantId": "variant_234"
}'

JavaScript (React)

import axios from "axios";

const removeItemFromCart = async () => {
try {
const response = await axios.delete("https://dev-sfapi.unisouk.com/cart/item", {
headers: {
"Content-Type": "application/json",
Authorization: "Bearer <TOKEN>",
"x-store-id": "<STORE_ID>",
},
data: {
cartId: "cart_6oFGyknVpz8ltKuw",
variantId: "variant_234",
},
});

console.log("Item removed from cart:", response.data);
} catch (error) {
console.error("Error removing item from cart:", error.response?.data || error.message);
}
};

Sample Response

{
"message": "Cart Item Deleted Successfully",
"data": {
"id": "cart_PhIidALwQ8JFCBOU",
"storeId": "store_Vc3PvYOQrna9GOF7",
"customerId": "customer_123",
"totalAmount": 5000,
"items": [
{
"variantId": "variant_5wLljFpFc8Njgk1o",
"quantity": 50,
"price": 100
}
]
},
"source": "db"
}

Error Responses

Status CodeDescription
400Bad Request - Invalid parameters or missing required fields
401Unauthorized - Authentication token is missing or invalid
404Not Found - Cart or variant not found
500Internal Server Error - Something went wrong on the server

Notes

  • This endpoint completely removes the specified variant from the cart. If you wish to decrease the quantity instead, use the Update Cart Item endpoint.
  • If the removed item was the last item in the cart, the cart will be empty but still exist in the system.