Loading
Upcoming Mandatory Changes to Public Key Infrastructure (PKI)Read More
Salesforce Enforces New Security Requirements in Summer 2026Read More

How to Add Optional Products to Cart using postCartsItems API

Publish Date: Jun 24, 2026
Prerequisite(s)
Cart APIs, postCartsItems API, vlocity_cmt CPQ cart endpoint, bundle product, optional child product, cartId 801Pw00000vhatsIAA, root product 01tQD00000Qk4HuYAJ, optional component product 01tPw00000P5RHJIA3, itemId 01uPw00000bVM3mIAG
Task
How do I add an optional child product to a bundle using the postCartsItems API?
Steps

The sample API endpoint and payload format for adding an optional product to a cart.

API Endpoint:

/services/apexrest/{namespace}/v2/cpq/carts/{cart_ID}/items

Sample Payload:

{
  "methodName": "postCartsItems",
  "cartId": "<CartId>",
  "validate": true,
  "price": true,
  "hierarchy": -1,
  "items": [
    {
      "itemId": "<PricebookEntryId_of_OptionalProduct>",
      "parentId": "<LineItemId_of_ImmediateRealParent>",
      "parentHierarchyPath": "<Product2Id_of_RootParent>",
      "parentRecord": {
        "records": [
          {
            "productId": "<Product2Id_of_ParentBundle>",
            "productChildItemId": "<productChildItemDefinition_Id>",
            "productHierarchyPath": "<Product2Id_of_RootParent>",
            "action": "Add",
            "isVirtualItem": false,
            "displaySequence": -1,
            "defaultQuantity": 1,
            "minQuantity": 0,
            "maxQuantity": 99999,
            "Product2Id": "<Product2Id_of_ParentBundle>",
            "Id": {
              "value": "<LineItemId_of_ParentBundle>"
            },
            "productChildItemDefinition": {
              "Id": "<productChildItem_Id>",
              "vlocity_cmt__ParentProductId__c": "<Product2Id_of_ParentBundle>",
              "vlocity_cmt__IsRootProductChildItem__c": true,
              "vlocity_cmt__IsOptional__c": true,
              "vlocity_cmt__IsOverride__c": false,
              "vlocity_cmt__CollapseHierarchy__c": false,
              "vlocity_cmt__IsVirtualItem__c": false,
              "vlocity_cmt__Quantity__c": 1
            }
          }
        ]
      }
    }
  ]
}

You can modify the placeholder values in the payload according to your specific use case and product hierarchy requirements.

Knowledge Article Number

005387550

 
Loading
Salesforce Help | Article