Store Kit
Cart

Remove from Cart

Remove an item from the customer's cart

Remove from Cart

Remove an item from the customer's cart. This endpoint removes a specific cart item identified by its unique cart ID from the cart associated with the current session or authenticated customer.

Endpoint

DELETE /v1/cart

Base URL: https://api.storekit.app

Authentication

Info: All API requests require authentication using an API key. Generate your API key from the StoreKit Dashboard under API Key Usage section.

Headers

NameTypeRequiredDescription
x-api-keystringYesYour API key for authentication
Content-TypestringYesMust be application/json

Request Body

FieldTypeRequiredDescription
cartIdstringYesUnique identifier of the cart item to remove

Request Example

{
  "cartId": "cmcqc7h5l000zp92bz94zgl7v"
}

Response

Success Response (200 OK)

{
  "success": true,
  "message": "Item removed from cart successfully...!!!"
}

Response Schema

FieldTypeDescription
successbooleanIndicates if the request was successful
messagestringDescriptive message about the operation

Error Responses

401 Unauthorized

{
  "error": "API key is required"
}

403 Forbidden

{
  "success": false,
  "message": "Not authorized to remove this item"
}

404 Not Found

{
  "success": false,
  "message": "Cart item not found"
}

422 Unprocessable Entity

{
  "success": false,
  "message": "Validation error",
  "errors": [
    {
      "code": "invalid_type",
      "expected": "string",
      "received": "undefined",
      "path": ["cartId"],
      "message": "Required"
    }
  ]
}

500 Internal Server Error

{
  "success": false,
  "message": "Internal server error"
}

Code Examples

curl -X DELETE "https://api.storekit.app/v1/cart" \
  -H "x-api-key: sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402" \
  -H "Content-Type: application/json" \
  -d '{
    "cartId": "cmcqc7h5l000zp92bz94zgl7v"
  }'
const response = await fetch("https://api.storekit.app/v1/cart", {
  method: "DELETE",
  headers: {
    "x-api-key":
      "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    cartId: "cmcqc7h5l000zp92bz94zgl7v",
  }),
});

const data = await response.json();

if (data.success) {
  console.log("Success:", data.message);
} else {
  console.error("Error:", data.message);
}
import axios from "axios";

try {
  const response = await axios.delete(
    "https://api.storekit.app/v1/cart",
    {
      data: {
        cartId: "cmcqc7h5l000zp92bz94zgl7v",
      },
      headers: {
        "x-api-key":
          "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
        "Content-Type": "application/json",
      },
    }
  );

  const { success, message } = response.data;

  if (success) {
    console.log("Success:", message);
  } else {
    console.error("Error:", message);
  }
} catch (error) {
  console.error("Request failed:", error.response?.data || error.message);
}
const https = require("https");

const postData = JSON.stringify({
  cartId: "cmcqc7h5l000zp92bz94zgl7v",
});

const options = {
  hostname: "api.storekit.app",
  port: 443,
  path: "/v1/cart",
  method: "DELETE",
  headers: {
    "x-api-key":
      "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
    "Content-Type": "application/json",
    "Content-Length": Buffer.byteLength(postData),
  },
};

const req = https.request(options, (res) => {
  let data = "";

  res.on("data", (chunk) => {
    data += chunk;
  });

  res.on("end", () => {
    const result = JSON.parse(data);

    if (result.success) {
      console.log("Success:", result.message);
    } else {
      console.error("Error:", result.message);
    }
  });
});

req.on("error", (error) => {
  console.error("Request failed:", error);
});

req.write(postData);
req.end();
import requests
import json

url = "https://api.storekit.app/v1/cart"
headers = {
    "x-api-key": "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
    "Content-Type": "application/json"
}

payload = {
    "cartId": "cmcqc7h5l000zp92bz94zgl7v"
}

try:
    response = requests.delete(url, headers=headers, json=payload)
    response.raise_for_status()

    data = response.json()

    if data['success']:
        print(f"Success: {data['message']}")
    else:
        print(f"Error: {data['message']}")

except requests.exceptions.RequestException as e:
    print(f"Request failed: {e}")
<?php
$curl = curl_init();

$payload = json_encode([
    'cartId' => 'cmcqc7h5l000zp92bz94zgl7v'
]);

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.storekit.app/v1/cart",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_POSTFIELDS => $payload,
    CURLOPT_HTTPHEADER => [
        "x-api-key: sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
        "Content-Type: application/json"
    ],
]);

$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

$data = json_decode($response, true);

if ($httpCode === 200 && $data['success']) {
    echo "Success: " . $data['message'] . "\n";
} else {
    echo "Error: " . $data['message'] . "\n";
}
?>
$.ajax({
  url: "https://api.storekit.app/v1/cart",
  method: "DELETE",
  headers: {
    "x-api-key":
      "sk_live_be186797384f05ff038e1751e8ff9572cf8a05adfdba79abb7e8bcd165f2c402",
    "Content-Type": "application/json",
  },
  data: JSON.stringify({
    cartId: "cmcqc7h5l000zp92bz94zgl7v",
  }),
  success: function (data) {
    if (data.success) {
      console.log("Success:", data.message);
      
      // Example: Remove item from UI
      $(`[data-cart-id="${data.cartId}"]`).fadeOut();
      $("#cart-message").text(data.message).addClass("success");
    } else {
      console.error("Error:", data.message);
    }
  },
  error: function (xhr, status, error) {
    console.error("Request failed:", error);
    
    // Handle different error types
    if (xhr.responseJSON) {
      $("#cart-message").text(xhr.responseJSON.message).addClass("error");
    }
  },
});

Authentication & Session Management

This endpoint automatically handles both authenticated and anonymous users:

  • Authenticated users: Only items belonging to their customer account can be removed
  • Anonymous users: Only items associated with their session can be removed

The API performs authorization checks to ensure users can only remove items from their own cart.

Authorization & Security

The endpoint includes built-in security measures:

  • Ownership Verification: The API verifies that the cart item belongs to the requesting customer
  • Session-based Authorization: For anonymous users, cart items are matched against the session ID
  • Account-based Authorization: For authenticated users, cart items are matched against the customer ID

Error Handling

The API returns specific error codes for different scenarios:

  • Missing API Key: Returns 401 with message "API key is required"
  • Invalid Cart ID: Returns 404 with message "Cart item not found"
  • Missing Cart ID: Returns 404 with message "Cart item not found"
  • Invalid Request Data: Returns 422 with validation errors
  • Server Error: Returns 500 with message "Internal server error"

Important Notes

  • The cartId must be a valid identifier for an existing cart item
  • Users can only remove items from their own cart (security enforced)
  • Session data is automatically managed through cookies
  • API key is required for all requests and can be generated in your StoreKit Dashboard

Customer Context

Info: This endpoint uses customer identification middleware with authorization checks:

  • Authenticated users: Can only remove items where customerId matches their account
  • Guest users: Can only remove items where sessionId matches their current session

Use Cases

  • Remove unwanted items from shopping cart
  • Clean up cart items before checkout
  • Handle cart management in e-commerce applications
  • Implement "Remove" buttons in cart UI components

Quick Start

Step 1: Get your API Key

Navigate to your StoreKit Dashboard and go to the API Key Usage section to generate your API key.

Step 2: Get the Cart ID

First, retrieve the cart items to get the cartId of the item you want to remove (use the Get Cart Items endpoint).

Step 3: Make the request

Use any of the code examples above to remove the item from the cart. The API will automatically verify ownership and authorization.

Step 4: Handle the response

Check the success field and handle any errors appropriately. Update your UI to reflect the removal of the item from the cart.

Status Codes

Status CodeDescriptionResponse Example
200Success - Item removed successfully{ "success": true, "message": "Item removed from cart successfully...!!!" }
401Unauthorized - Missing or invalid API key{ "error": "API key is required" }
403Forbidden - Not authorized to remove this item{ "success": false, "message": "Not authorized to remove this item" }
404Not Found - Cart item not found or invalid cart ID{ "success": false, "message": "Cart item not found" }
422Unprocessable Entity - Invalid input data{ "success": false, "message": "Validation error", "errors": [...] }
500Internal Server Error - Server error while removing item{ "success": false, "message": "Internal server error" }