This use case describes how to interact with the cart, which stores details about the product you configure from the catalog, including options, attributes, and pricing configuration. Implementation teams can use these APIs to build a cart as necessary to prepare a product configuration by providing relevant details. These APIs also enable actions on the cart to activate and price the product configuration.

Retrieving a List of Carts

You can retrieve all carts with their details where the requester is the creator, owner of, or has access to the cart. Retrieving carts helps you explore the carts before you check them out. This API retrieves the following details:

  • Cart name
  • Effective date of the cart

Method: GET
Endpoint: /carts

You can use the query parameters available in the API to sort or filter carts based on specific requirements. For example, you have access to 1000 carts and retrieve them as follows.

APIPurpose

GET/carts?Page=1&limit=20&sort=asc(Name)

Retrieves only the first 2 carts sorted alphabetically based on cart names.

GET/carts?Page=1&limit=30&sort=desc(EffectiveDate)

Retrieves only the first 2 carts sorted based on the effective dates of carts in descending order.

For the following values:

ParametersValue
page1
limit2
sortdesc(EffectiveDate)

The below is the request URL and after executing that:

Request

'GET' \'https://<URL_of_the_Instance>/api/cart/v1/carts?sort=asc%28Name%29&page=1&limit=2' \
CODE

You get the following response:

Response

[
  {
    "Account": {
      "Id": "d80484e9-6a11-4019-8bab-7733726f068a",
      "Name": "Auto_IncStartAndEndDateCR_Account001"
    },
    "Ancestor": null,
    "ApprovalStatus": null,
    "BaseRelationCount": null,
    "BillingPreference": null,
    "BillToAccount": null,
    "BusinessObjectId": null,
    "BusinessObjectProfile": "Regular",
    "BusinessObjectRefId": null,
    "BusinessObjectType": "Agreement",
    "Comments": null,
    "ContractNumbers": null,
    "CostRollupInfo": null,
    "CouponCodes": null,
    "CurrentUser": null,
    "Description": "Cart1 Created with automation script",
    "EffectiveDate": "2023-06-30T00:00:00",
    "EffectivePriceList": {
      "Id": "ca40ab42-1756-4047-851e-29ca7568ed80",
      "Name": "Auto_IncStartAndEndDateCR_PL001"
    },
    "ExpectedEndDate": null,
    "ExpectedStartDate": null,
    "FinalizedDate": null,
    "Intent": null,
    "IsPricePending": false,
    "IsTaskPending": false,
    "IsTransient": false,
    "IsValidationPending": false,
    "LineItemsAwaitingPrice": null,
    "LegalEntity": null,
    "Location": null,
    "NumberOfItems": 0,
    "Order": null,
    "ParentConfiguration": null,
    "PaymentTerm": null,
    "PriceList": {
      "Id": "ca40ab42-1756-4047-851e-29ca7568ed80",
      "Name": "Auto_IncStartAndEndDateCR_PL001"
    },
    "PricingDate": "2023-06-30T00:00:00",
    "Primordial": null,
    "PurchaseId": null,
    "RenewalAdjustmentAmount": null,
    "RenewalAdjustmentType": null,
    "ShipToAccount": null,
    "SplitCriteriaKey": null,
    "Status": "New",
    "SummaryGroupType": "Category",
    "TaskCompletedDate": null,
    "UseType": "Main",
    "VersionNumber": null,
    "ActivationDate": null,
    "Id": "e42d09d9-6498-4b5b-8529-54a8826ab341",
    "Name": "Auto_IncStartAndEndDateCR_Cart001",
    "CreatedBy": {
      "Id": "27634e3f-904a-4321-9ce5-c2edbe181d90",
      "Name": "Test User"
    },
    "CreatedDate": "2022-11-16T01:09:06",
    "ModifiedBy": {
      "Id": "27634e3f-904a-4321-9ce5-c2edbe181d90",
      "Name": "Test User"
    },
    "ModifiedDate": "2022-11-16T01:09:06",
    "ExternalId": null,
    "PDTest_CustomField_c": "Custom Field Default Value",
    "ActivationDate_c": null
  },
  {
    "Account": {
      "Id": "c8a3e8e3-ceba-46a9-9dae-84058e8dd4a2",
      "Name": "Auto_IncStartAndEndDateCR_Account001"
    },
    "Ancestor": null,
    "ApprovalStatus": null,
    "BaseRelationCount": null,
    "BillingPreference": null,
    "BillToAccount": null,
    "BusinessObjectId": null,
    "BusinessObjectProfile": "Regular",
    "BusinessObjectRefId": null,
    "BusinessObjectType": "Agreement",
    "Comments": null,
    "ContractNumbers": null,
    "CostRollupInfo": null,
    "CouponCodes": null,
    "CurrentUser": null,
    "Description": "Cart1 Created with automation script",
    "EffectiveDate": "2023-06-30T00:00:00",
    "EffectivePriceList": {
      "Id": "8f58849c-ae90-4040-865d-8c67432e0ae1",
      "Name": "Auto_IncStartAndEndDateCR_PL001"
    },
    "ExpectedEndDate": null,
    "ExpectedStartDate": null,
    "FinalizedDate": null,
    "Intent": null,
    "IsPricePending": false,
    "IsTaskPending": false,
    "IsTransient": false,
    "IsValidationPending": false,
    "LineItemsAwaitingPrice": null,
    "LegalEntity": null,
    "Location": null,
    "NumberOfItems": 0,
    "Order": null,
    "ParentConfiguration": null,
    "PaymentTerm": null,
    "PriceList": {
      "Id": "8f58849c-ae90-4040-865d-8c67432e0ae1",
      "Name": "Auto_IncStartAndEndDateCR_PL001"
    },
    "PricingDate": "2023-06-30T00:00:00",
    "Primordial": null,
    "PurchaseId": null,
    "RenewalAdjustmentAmount": null,
    "RenewalAdjustmentType": null,
    "ShipToAccount": null,
    "SplitCriteriaKey": null,
    "Status": "New",
    "SummaryGroupType": "Category",
    "TaskCompletedDate": null,
    "UseType": "Main",
    "VersionNumber": null,
    "ActivationDate": null,
    "Id": "72da7e2d-0fb5-49c3-9124-effc819ee424",
    "Name": "Auto_IncStartAndEndDateCR_Cart001",
    "CreatedBy": {
      "Id": "27634e3f-904a-4321-9ce5-c2edbe181d90",
      "Name": "Test User"
    },
    "CreatedDate": "2022-11-15T14:48:59",
    "ModifiedBy": {
      "Id": "27634e3f-904a-4321-9ce5-c2edbe181d90",
      "Name": "Test User"
    },
    "ModifiedDate": "2022-11-15T14:48:59",
    "ExternalId": null,
    "PDTest_CustomField_c": "Custom Field Default Value",
    "ActivationDate_c": null
  }
]
CODE


Activating a Cart

Of all carts, only one cart can be active. You can activate a cart that is in the "New" status only. You cannot activate a cart in other statuses such as Finalized, Superseded, Suspended, Abandoned, or Deleted. Activating a cart does not change anything on the cart, except marking the cart as "Active". This API allows you to work on any existing cart that is not checked out yet.

Method: POST
Endpoint: /carts/{CartId}/activate

For example, you want to activate a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919. Execute the following API:

POST/carts/b6c8762a-2c14-49b0-9a46-bebe4044c919/activate
CODE

Retrieving Cart Details (Header Information)

You can retrieve the header details of a cart. This API retrieves the following details among others:

  • Cart name
  • Price list
  • Account
  • Effective date
  • Link to the business object if the cart is finalized

Method: GET
Endpoint: /carts/{cartId}

For example, the following sample code enables you to get the header details of a cart with the cart ID e42d09d9-6498-4b5b-8529-54a8826ab34. 

Request

'GET' \ 'https://<URL_of_the_Instance>/api/cart/v1/carts/e42d09d9-6498-4b5b-8529-54a8826ab341' \
CODE

You get the following response:

Response

{
  "Account": {
    "Id": "d80484e9-6a11-4019-8bab-7733726f068a",
    "Name": "Auto_IncStartAndEndDateCR_Account001"
  },
  "Ancestor": null,
  "ApprovalStatus": null,
  "BaseRelationCount": null,
  "BillingPreference": null,
  "BillToAccount": null,
  "BusinessObjectId": null,
  "BusinessObjectProfile": "Regular",
  "BusinessObjectRefId": null,
  "BusinessObjectType": "Agreement",
  "Comments": null,
  "ContractNumbers": null,
  "CostRollupInfo": null,
  "CouponCodes": null,
  "CurrentUser": null,
  "Description": "Cart1 Created with automation script",
  "EffectiveDate": "2023-06-30T00:00:00",
  "EffectivePriceList": {
    "Id": "ca40ab42-1756-4047-851e-29ca7568ed80",
    "Name": "Auto_IncStartAndEndDateCR_PL001"
  },
  "ExpectedEndDate": null,
  "ExpectedStartDate": null,
  "FinalizedDate": null,
  "Intent": null,
  "IsPricePending": false,
  "IsTaskPending": false,
  "IsTransient": false,
  "IsValidationPending": false,
  "LineItemsAwaitingPrice": null,
  "LegalEntity": null,
  "Location": null,
  "NumberOfItems": 0,
  "Order": null,
  "ParentConfiguration": null,
  "PaymentTerm": null,
  "PriceList": {
    "Id": "ca40ab42-1756-4047-851e-29ca7568ed80",
    "Name": "Auto_IncStartAndEndDateCR_PL001"
  },
  "PricingDate": "2023-06-30T00:00:00",
  "Primordial": null,
  "PurchaseId": null,
  "RenewalAdjustmentAmount": null,
  "RenewalAdjustmentType": null,
  "ShipToAccount": null,
  "SplitCriteriaKey": null,
  "Status": "New",
  "SummaryGroupType": "Category",
  "TaskCompletedDate": null,
  "UseType": "Main",
  "VersionNumber": null,
  "ActivationDate": null,
  "Id": "e42d09d9-6498-4b5b-8529-54a8826ab341",
  "Name": "Auto_IncStartAndEndDateCR_Cart001",
  "CreatedBy": {
    "Id": "27634e3f-904a-4321-9ce5-c2edbe181d90",
    "Name": "Test User"
  },
  "CreatedDate": "2022-11-16T01:09:06",
  "ModifiedBy": {
    "Id": "27634e3f-904a-4321-9ce5-c2edbe181d90",
    "Name": "Test User"
  },
  "ModifiedDate": "2022-11-16T01:09:06",
  "ExternalId": null,
  "PDTest_CustomField_c": "Custom Field Default Value",
  "ActivationDate_c": null
}
CODE


Retrieving Line Items of the Cart

You can retrieve all line items in a cart, with their details. The API retrieves the following details:

  • Cart header fields
  • Primary line items
  • Secondary line items associated with the primary line items such as options and charge types

Method: GET
Endpoint: /carts/{cartId}/items

For example, you want to get the details of all line items in a cart with the cart ID e42d09d9-6498-4b5b-8529-54a8826ab341. Execute the following API:

Request

'GET' \'https://<URL_of_the_Instance>/api/cart/v1/carts/e42d09d9-6498-4b5b-8529-54a8826ab341/items'
CODE

You can use the query parameters available in the API to sort or filter cart line items based on specific requirements. For example, a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919 has 1000 cart line items and you retrieve them as follows.

APIPurpose

GET/carts/{b6c8762a-2c14-49b0-9a46-bebe4044c919}/items&page=1&limit=20&sort=asc(Name)

Retrieves only the first 20 cart line items sorted alphabetically based on their names.

Adding Line Items to the Cart

You can add one or more standalone, bundle, and option products to the cart. You can add bundle line items with the default or modified configuration. You cannot add products to a cart in the Finalized, Superseded, or Deleted status.

Method: POST
Endpoint: /carts/{cartId}/items

For example, you want to add line items to a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919. Execute the following API:

POST/carts/b6c8762a-2c14-49b0-9a46-bebe4044c919/items
CODE

You must pass the product ID in the request body to add the product to the cart. You can add products with different field values.

Scenarios

  • In the following example, you add multiple standalone products with different field values. You pass the following parameters in the request body:

    Request Body

    [
    	{
    		"PrimaryTxnLineNumber": 100001,
    		"Product": {
    			"Id": "44a35bef-6d8d-420a-9d7a-3c443c304f05",
    			"Name": "Product_1"
    		},
    		"ExternalId": "45c8a8c8-7b94-419f-94b0-9e8f14d35696",
    		"LineType": "Product/Service",
    		"PricingStatus": "Pending",
    		"Quantity": 1
    	},
    	{
    		"PrimaryTxnLineNumber": 100002,
    		"Product": {
    			"Id": "ad590285-ac23-4182-9137-9a1b294842f2",
    			"Name": "Product_2"
    		},
    		"ExternalId": "beed1ffe-1317-4bbb-a3b9-6a57c303a43a",
    		"LineType": "Product/Service",
    		"PricingStatus": "Pending",
    		"Quantity": 1
    	},
    	{
    		"PrimaryTxnLineNumber": 100003,
    		"Product": {
    			"Id": "71dda149-7dcc-4f37-8c67-a5c4b927afe5",
    			"Name": "Product_3"
    		},
    		"ExternalId": "f49c3693-d1ee-4590-83f3-f30102fef080",
    		"LineType": "Product/Service",
    		"PricingStatus": "Pending",
    		"Quantity": 1
    	}
    ]
    CODE
  • In the following example, you add option to the Bundle products. You pass the following parameters in the request body:

    [
        {
            "IsPrimaryLine": true,
            "LineType": "Product/Service",
            "PricingStatus": "Pending",
            "Product": {
                "Id": "9872ad8d-87c7-4a7c-ab49-c9332ce2fb0e",
                "Name": "n1"
            },
            "ExternalId": "Auto_BundleOnly_LineItem001",
            "PrimaryTxnLineNumber": 1,
            "StartDate": "2024-01-01",
            "EndDate": "2024-01-31",
            "AdjustmentAmount": 10.123456789,
            "AdjustmentType": "% Discount"
        },
        {
            "IsPrimaryLine": true,
            "LineType": "Option",
            "TxnParentBundleNumber": "1",
            "Option": {
                "Id": "9872ad8d-87c7-4a7c-ab19-c9332ce2fb0e",
                "Name": "n2"
            },
            "PricingStatus": "Pending",
            "Product": {
                "Id": "9872ad8d-87c7-4a7c-ab49-c9332ce2fb0e",
                "Name": "n1"
            },
            "ExternalId": "Auto_BundleOption_LineItem002",
            "PrimaryTxnLineNumber": 2
        }
    ]
    CODE

Updating an Existing Cart Item

You can update one or more existing cart line items by providing details of the following fields in the request body:

  • Quantity
  • Selling Term
  • Start Date
  • End Date
  • Adjustment Amount
  • Adjustment Type

You cannot update custom fields. You cannot update line items in a cart in the Finalized, Superseded, or Deleted status.

Method: PATCH
Endpoint: /carts/{cartId}/items

For example, you want to update line items in a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919. Execute the following API:

PATCH/carts/b6c8762a-2c14-49b0-9a46-bebe4044c919/items
CODE

In the request body, you must pass the product ID and the required fields with values to update the cart line items.

Scenarios

  • In the following example, you update the quantity of an existing cart line item.

    [
        {
            "PrimaryTxnLineNumber": "1",
            "ProductId": "6e6619b8-8d2e-4686-af69-b16e683b98f9",
            "LineType": "Product/Service",
            "LineNumber" : 1,
            "PrimaryLineNumber" :1,
            "PricingStatus": "Pending",
            "Id": "494f0297-d63a-46b1-a71a-689ad5409a3f",
            "Quantity": 10,
            "ExternalId": "Standalone"
        }
    ]
    CODE
  • In the following example, you update the selling term of an existing cart line item:

    [
        {
            "PrimaryTxnLineNumber": "1",
            "ProductId": "6e6619b8-8d2e-4686-af69-b16e683b98f9",
            "LineType": "Product/Service",
            "LineNumber": 1,
            "PrimaryLineNumber": 1,
            "PricingStatus": "Pending",
            "Id": "494f0297-d63a-46b1-a71a-689ad5409a3f",
            "Quantity": 10,
            "ExternalId": "Standalone",
            "SellingTerm" : 5
        }
    ]
    CODE

Removing Line Items from the Cart

You can remove one or more line items from the cart. You cannot remove line items from a cart in the Finalized, Superseded, or Deleted status.

Method: DELETE
Endpoint: /carts/{cartId}/items

For example, you want to remove line items from a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919. Execute the following API:

DELETE/carts/b6c8762a-2c14-49b0-9a46-bebe4044c919/items
CODE

In the request body, you provide IDs of cart line items to remove the associated records from the cart.

Scenario

In the following example, you remove one cart line item.

[
  {
    "LineNumber": 0
  },
  {
    "CartItemId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  }
]

CODE

Run Pricing on the Cart

You must calculate pricing on the cart whenever you add any product(s) to the cart and/or configure products from the catalog. CPQ does not run pricing on the cart by default, so you must do it explicitly. Following are some of the scenarios to call this API:

  • Adding a standalone product to the cart
  • Adding a bundle product and configuring its options
  • Selecting different charge types
  • Configuring product attributes or modifying them
  • Changing the default quantity (that is 1) on the Catalog page while adding/configuring the products
  • Deselecting an added product from the catalog

You must also perform repricing of the cart whenever you update the cart. Following are some of the scenarios to reprice the cart:

  • Changing any cart line item fields such as Quantity, Selling Term, Start Date, End Date, Base Price
  • Applying any kind of adjustments on any cart line item
  • Performing actions such Mass Update
  • Adding or removing any line item
  • Configuring any line item for options, attributes, or other parameters

Method: POST
Endpoint: /carts/{cartId}/price

For example, you want to price or reprice a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919. Execute the following API:

POST/carts/b6c8762a-2c14-49b0-9a46-bebe4044c919/price
CODE

Deleting a Cart

You can delete a cart when it is no longer required. A deleted cart record is not stored so you cannot access it after deletion.

Method: DELETE
Endpoint: /carts/{cartId}

For example, you want to delete a cart with the cart ID b6c8762a-2c14-49b0-9a46-bebe4044c919. Execute the following API:

DELETE/carts/b6c8762a-2c14-49b0-9a46-bebe4044c919
CODE