---
schema_version: "1"
id: 96e4795f49d90d626dd04f7f281c071642432eb506ac9308efc93f0eb67f1f35
title: Get Line Items by ID
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-get-line-items-by-id.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-get-line-items-by-id.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a0f44e31c47df93e22745d2a17683610b7a61ee87346b4333fbbb2bfe072231c
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Get Line Items by ID

Return the items and configurable attributes based on item IDs.

```nolang
GET /v2/cpq/carts/{cart_ID}/items?id={item_ID},{item_ID}&validate={true|false}
```

## Get Cart Items Trim Mode

Trim Mode is an optimization feature that reduces the payload size of the GetCartItems API response. Instead of returning the full set of cart item fields, Trim Mode restricts the response to only what is explicitly required.

When enabled, the API response includes these:

- A fixed set of 22 default fields (identity, hierarchy, and status)
- Fields specified via the fields query parameter
- Fields defined in the `GCITrimFieldsToInclude` field set in Salesforce

All other fields are removed from the response. Structural nodes such as `PricebookEntry`, `Product2`, and `productChildItemDefinition` are always preserved.

**important:** Trim Mode applies only to:

- getCartItemList
- getCartItemListById

See, [Enabling Trim Mode](#enabling-trim-mode)

## Remote Method

```nolang
getCartsItemsById
```

## REST Handler

```nolang
APIItemsCartsCpqV2
```

## Apex Remote Service

```nolang
CpqAppHandler
```


## Apex Remote Input Map

```nolang
{
  methodName:getCartsItemsById,
  cartId:801360000008eNU,
  id:01t36000000pfcKAAQ,01t36000000pfcKAAQ
}
cartId = order.Id, opportunity.Id, quote.Id
```

## 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=80236000000Z0QNAA0,01t36000000pfcKAAQ&validate=true |

## Example Request

```nolang
GET
/services/apexrest/vlocity_cmt/v2/cpq/carts/80136000000aSTqAAM/items?id=80236000000Z0QNAA0,01t36000000pfcKAAQ&validate=true
```

## Example Result

**note:** - An entire result can be thousands of lines long. This example has been truncated.
- If a child line item Id is passed in the input request, then the whole bundle is returned in the response.

```nolang
{
  "totalSize": 1,
  "messages": [],
  "records": [
    {
      "messages": [],
      "actions": {
        "addtocart": {
          "rest": {
            "params": {
              "items": [
                {
                  "quantity": 1,
                  "parentId": "8021I00000186qVQAQ",
                  "itemId": "01u1I000000wj9IQAQ"
                }
              ],
              "cartId": "8011I000000KN9dQAG",
              "price": true,
              "validate": true,
              "includeAttachment": false,
              "pagesize": 10,
              "lastRecordId": null,
              "query": null
            },
            "method": "POST",
            "link": "/services/apexrest/vlocity_cmt/v2/cpq/carts/8011I000000KN9dQAG/items"
          },
          "remote": {
            "params": {
              "methodName": "postCartsItems",
              "items": [
                {
                  "quantity": 1,
                  "parentId": "8021I00000186qVQAQ",
                  "itemId": "01u1I000000wj9IQAQ"
                }
              ],
              "cartId": "8011I000000KN9dQAG",
              "price": true,
              "validate": true,
              "includeAttachment": false,
              "pagesize": 10,
              "lastRecordId": null,
              "query": null
            }
          },
          "client": {
            "params": {}
          }
        },
        "updateitems": {
          "rest": {
            "params": {
              "items": [
                {
                  "itemId": "8021I00000186qVQAQ"
                }
              ],
              "filters": null,
              "fields": "vlocity_cmt__BillingAccountId__c, vlocity_cmt__ServiceAccountId__c, Quantity, vlocity_cmt__RecurringTotal__c, vlocity_cmt__OneTimeTotal__c, vlocity_cmt__OneTimeManualDiscount__c, vlocity_cmt__RecurringManualDiscount__c, vlocity_cmt__ProvisioningStatus__c, vlocity_cmt__RecurringCharge__c, vlocity_cmt__OneTimeCharge__c, ListPrice, vlocity_cmt__ParentItemId__c, vlocity_cmt__BillingAccountId__r.Name, vlocity_cmt__ServiceAccountId__r.Name, vlocity_cmt__PremisesId__r.Name, vlocity_cmt__InCartQuantityMap__c",
              "cartId": "8011I000000KN9dQAG",
              "price": true,
              "validate": true,
              "includeAttachment": false,
              "pagesize": 10,
              "lastRecordId": null,
              "query": null
            },
            "method": "PUT",
            "link": "/services/apexrest/vlocity_cmt/v2/cpq/carts/8011I000000KN9dQAG/items"
          },
          "remote": {
            "params": {
              "methodName": "putCartsItems",
              "items": [
                {
                  "itemId": "8021I00000186qVQAQ"
                }
              ],
              "filters": null,
              "fields": "vlocity_cmt__BillingAccountId__c, vlocity_cmt__ServiceAccountId__c, Quantity, vlocity_cmt__RecurringTotal__c, vlocity_cmt__OneTimeTotal__c, vlocity_cmt__OneTimeManualDiscount__c, vlocity_cmt__RecurringManualDiscount__c, vlocity_cmt__ProvisioningStatus__c, vlocity_cmt__RecurringCharge__c, vlocity_cmt__OneTimeCharge__c, ListPrice, vlocity_cmt__ParentItemId__c, vlocity_cmt__BillingAccountId__r.Name, vlocity_cmt__ServiceAccountId__r.Name, vlocity_cmt__PremisesId__r.Name, vlocity_cmt__InCartQuantityMap__c",
              "cartId": "8011I000000KN9dQAG",
              "price": true,
              "validate": true,
              "includeAttachment": false,
              "pagesize": 10,
              "lastRecordId": null,
              "query": null
            }
          },
          "client": {
            "params": {}
          }
        },
        "deleteitem": {
          "rest": {
            "params": {},
            "method": "DELETE",
            "link": "/services/apexrest/vlocity_cmt/v2/cpq/carts/8011I000000KN9dQAG/items/ 8021I00000186qVQAQ?pagesize=10&includeAttachment=false& validate=true&price=true&cartId=8011I000000KN9dQAG&fields= vlocity_cmt__BillingAccountId__c, vlocity_cmt__ServiceAccountId__c, Quantity, vlocity_cmt__RecurringTotal__c, vlocity_cmt__OneTimeTotal__c, vlocity_cmt__OneTimeManualDiscount__c, vlocity_cmt__RecurringManualDiscount__c, vlocity_cmt__ProvisioningStatus__c, vlocity_cmt__RecurringCharge__c, vlocity_cmt__OneTimeCharge__c, ListPrice, vlocity_cmt__ParentItemId__c, vlocity_cmt__BillingAccountId__r.Name, vlocity_cmt__ServiceAccountId__r.Name, vlocity_cmt__PremisesId__r.Name, vlocity_cmt__InCartQuantityMap__c & id = 8021I00000186qVQAQ"
          },
          "remote": {
            "params": {
              "methodName": "deleteCartsItems",
              "id": "8021I00000186qVQAQ",
              "filters": null,
              "fields": "vlocity_cmt__BillingAccountId__c, vlocity_cmt__ServiceAccountId__c, Quantity, vlocity_cmt__RecurringTotal__c, vlocity_cmt__OneTimeTotal__c, vlocity_cmt__OneTimeManualDiscount__c, vlocity_cmt__RecurringManualDiscount__c, vlocity_cmt__ProvisioningStatus__c, vlocity_cmt__RecurringCharge__c, vlocity_cmt__OneTimeCharge__c, ListPrice, vlocity_cmt__ParentItemId__c, vlocity_cmt__BillingAccountId__r.Name, vlocity_cmt__ServiceAccountId__r.Name, vlocity_cmt__PremisesId__r.Name, vlocity_cmt__InCartQuantityMap__c",
              "cartId": "8011I000000KN9dQAG",
              "price": true,
              "validate": true,
              "includeAttachment": false,
              "pagesize": 10,
              "lastRecordId": null,
              "query": null
            }
          },
          "client": {
            "params": {}
          }
        },
        "configdelete": {
          "rest": {
            "params": {},
            "method": null,
            "link": null
          },
          "remote": {
            "params": {
              "methodName": "configDeleteItem",
              "id": "8021I00000186qVQAQ",
              "cartId": "8011I000000KN9dQAG"
            }
          },
          "client": {
            "params": {}
          }
        },
        "cloneitem": {
          "rest": {
            "params": {
              "items": [
                {
                  "itemId": "8021I00000186qVQAQ"
                }
              ],
              "id": "8021I00000186qVQAQ",
              "cartId": "8011I000000KN9dQAG"
            },
            "method": "POST",
            "link": "/services/apexrest/vlocity_cmt/v2/cpq/carts/8011I000000KN9dQAG/items/ clone"
          },
          "remote": {
            "params": {
              "methodName": "cloneItems",
              "items": [
                {
                  "itemId": "8021I00000186qVQAQ"
                }
              ],
              "id": "8021I00000186qVQAQ",
              "cartId": "8011I000000KN9dQAG"
            }
          },
          "client": {
            "params": {}
          }
        },
        "modifyattributes": {
          "rest": {
            "params": {
              "items": [
                {
                  "itemId": "8021I00000186qVQAQ"
                }
              ],
              "filters": null,
              "itemId": "8021I00000186qVQAQ",
              "id": "8021I00000186qVQAQ",
              "cartId": "8011I000000KN9dQAG"
            }
          }
        }
      }
    }
  ]
}
```

**note:** To validate or price a bundle, pass the rootItemId instead of the itemId.

## Enabling Trim Mode

**Option 1: Per-Request (Recommended for Controlled Adoption)**

Enable Trim Mode for specific API calls using a query parameter:
`/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartId}/items?gciTrimMode=true`
`/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartId}/items?gciTrimMode=true&fields=UnitPrice,vlocity_cmt\_\_OneTimeCost\_\_c`

Use this approach for:

- Targeted integrations
- Specific UI components
- Testing and gradual rollout

**Option 2: Org-Wide Configuration**

Enable Trim Mode globally via CPQ configuration:

- Set `gciTrimMode = true` in CPQ Configuration Setup. This applies to all GetCartItems API calls across the organization.
- Configure field set:
  - Product2.Name
  - UnitPrice
  - TotalPrice
  - Description
    All responses include default fields, field set fields, and additional fields via fields parameter (if provided).

**important:** Trim Mode removes fields from the API response. Any code, UI, or integration that depends on those fields will break unless the fields are explicitly requested.

### Precedence Rules

| API Parameter | Config Setting | Result   |
| ------------- | -------------- | -------- |
| TRUE          | any            | Trim ON  |
| FALSE         | any            | Trim OFF |
| not provided  | TRUE           | Trim ON  |
| not provided  | false / unset  | Trim OFF |

The API parameter always takes precedence. Use `gciTrimMode = false` to override org-wide settings per request.

### Default Fields (Always Included)

These 22 fields are always present when trim mode is on, without needing to request them:

Id, RootItemId, ParentItemId, AssetReferenceId, LineNumber, Product2Id, PricebookEntryId, OrderId, QuoteId, OpportunityId, Quantity, Status, Action, IsRootItem,
ProductHierarchyPath, ProductHierarchyGroupKeyPath, BillingAccountId, ServiceAccountId, InCartQuantityMap, CpqMessageData, CpqCardinalityMessage, CpqPricingMessage

## Usage Examples

### Minimal Cart (Mobile Optimization)

`/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartId}/items?gciTrimMode=true&fields=Product2.Name,TotalPrice`

Returns a lightweight payload (~24 fields vs 150+).

### Cost Analysis Dashboard

`/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartId}/items?gciTrimMode=true&fields=UnitPrice,vlocity_cmt__OneTimeCost__c,vlocity_cmt__RecurringCost__c,vlocity_cmt__OneTimeMargin__c`

### Override Org-Wide Trim Mode

`/services/apexrest/vlocity_cmt/v2/cpq/carts/{cartId}/items?gciTrimMode=false`

Returns full response regardless of org settings.
