---
schema_version: "1"
id: ef83d976a4fe589c18b3b9b7aff6edb7e9b3f13474490c8260f82f004893ba0b
title: Remove Items from a Cart
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/standard_cart/std_comms-remove-items-from-cart.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/std_comms-remove-items-from-cart.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 53467c0c19740c78d964ee87fb48e3b28634c38fb3160d41bb58fa8bad1a3cbd
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Remove Items from a Cart

## Overview

The Delete Cart Items API (deleteCartsItems) removes one or more line items, stand-alone products, bundle members, auto-added promotions, or legacy asset rows, from a Cart (Quote/Order/Opportunity). Beyond the physical removal of rows, the call automatically:

- Cascades through bundle hierarchies (removing empty parents).
- Preserves or deletes promotions, depending on org policy.
- Re-evaluates bundle cardinality and, optionally, full pricing and validation rules so totals remain consistent.
- Returns deterministic success/error codes in a structured messages[] array.

## Typical Use Cases

- CSR Dashboards / CPQ Console – Agents undo mis‑clicks in real time; pricing/validation flags are set to true to keep the UI totals trustworthy.
- Self‑Service Portals – Shoppers remove add‑ons with price = false for latency; a later batch re‑prices the cart.
- Guided Selling Swaps – OmniScript deletes an obsolete SKU, then immediately adds the successor product in the same transaction.
- Nightly ETL Pruning – A middleware script processes 50 Ids at a time to guarantee all‑or‑nothing deletes.

## Key Benefits

### 1. Atomic Consistency

UOWMode shield prevents half‑processed batches, either every Id is removed or none.

### 2. Promotion Awareness

Built‑in guard rails ensure promotions remain fulfilled; or, when configured (DELETE_APPLIED_PROMO, DELETE_PROMO_ADDED_ITEMS), they’re cascaded out automatically.

### 3. Rule Enforcement

Internal logic reruns min/max logic and aborts if bundle limits would be breached (returns code 302 on failure).

### 4. Pluggable Engines

Flags let callers pay the CPU cost of Pricing/Validation only when needed.

### 5. Asset‑Aware Identifiers

Optional UseAssetReferenceIdForParentAndRoot switch allows "amend" journeys to address Assets even when the original Salesforce Ids have changed.

## Limitations & Caveats

- Hard Delete Only – The API performs disconnects which can’t be undone without an explicit add call.
- Promotion Guard is Opinionated – If a delete would leave a promotion under‑fulfilled and DELETE_APPLIED_PROMO = false, the whole call fails with error 406.
- Row Ownership – Items locked by an in‑flight pricing job (row‑level lock) will cause a retryable database exception; clients should implement exponential back‑off.
- Partial Bundles – Deleting a parent without children Ids when collapse empty parents is disabled will result in orphan rows; ensure hierarchy handling settings ( hierarchy=-1) are correct.

## Performance & Scalability

| Scenario                         | Median Latency | Notes                                   |
| -------------------------------- | -------------- | --------------------------------------- |
| 1 Line, price=false              | < 300 ms       | Avoids engine invocation.               |
| 10 Lines, price=true             | ~1 s           | Includes full Reprice + Advanced Rules. |
| 50 Lines, batch + validate=false | ~1.2 s         | Document layer bulk‑optimises DML.      |

## Security & Compliance

- Enforced by standard Salesforce CRUD/FLS on LineItem and Cart objects.
- All writes run inside Queueable Apex context, inheriting the integration user’s profile and OWD.
- The REST endpoint is covered by API Only User permission—lock down via named credentials for off‑platform integrations.

```
DELETE /v2/cpq/carts/{cart_Id}/items?id={line_item_id}
```

**note:** By default, items deleted from a cart are not evaluated for Vlocity Rules. To enable evaluation of deleted items, set the 'ShouldConsiderDeletedItems' custom setting to true.


Delete Items replaces the OmniCPQServiceWrapper `deleteItem` method.

This API supports the guest user enhancements that Salesforce introduced with the Winter ‘21 release. To encrypt and decrypt data for guest users, use the `UserSecurity` class with this API. See Guest User Technical Details.

For additional information, ​see UserSecurity Class and CPQ and Digital Commerce Changes for Guest Users.


## Rest Handler

```
APIItemsCartsCpqV2
```

## Rest Method

```
deleteCartsItems
```

## Remote Service

```
CpqAppHandler
```

## Remote Method

```
deleteCartsItems
```

## Apex Remote Input Map

```
Map<String, Object> inputMap = new Map<String, Object>{
    'cartId' => '{CART_ID}',
    'id' => '{LINE_ITEM_ID}',
    'validate' => true,
    'price' => true
};
Map<String, Object> outputMap = new Map<String, Object>();
Map<String, Object> optionsMap = new Map<String, Object>();
CpqAppHandler handler = new CpqAppHandler();
handler.invokeMethod('deleteCartsItems', inputMap, outputMap, optionsMap);
```

**note:** In releases prior to CME Spring '20, the deleteCartsItems method supports the deletion of one item at a time. If you must delete multiple items, make multiple deleteCartsItems calls.
With CME Spring '20 and later releases, the itemId parameter supports multiple comma-separated values when deleting root and child items via deleteCartsItems method calls if UOWMode is set to true.

## Package

Communication (vlocity_cmt)

## API Parameters and Response Format

For API parameter names and descriptions, see [Cart-Based API Swagger Reference](https://developer.salesforce.com/docs/industries/cme/references/cpq?meta=Summary).


## Resource Information

| Response Format | JSON                                                                      |
| --------------- | ------------------------------------------------------------------------- |
| Resource URL    | `/services/apexrest/{namespace}/v2/cpq/carts/{cart_Id}/items?id={itemId}` |

## Example Request

```
DELETE
/services/apexrest/vlocity_cmt/v2/cpq/carts/80141000000Cg8H/items?id=802xx000001nsbfAAA,802xx000001nsbgAAA
```

## Example Response

```
{
  "totalSize": 0,
  "messages": [{
      "code": "152",
      "severity": "INFO",
      "message": "Successfully deleted."
  }],
  "actions": {
    "itempricesupdated": {
      "remote": {
        "methodName": "getCartLineItemPrices",
        "params": {"cartId":"801xx000003H0D1AAK","price":false}
      }
    }
  }
}
```
