---
schema_version: "1"
id: adbae5aaba3ae11fb89c1bdf7ca8f7b1ca7ae5243ad9e15ae45b962426a8cb9c
title: "SDK Example: Create a Basket from an Asset (Winter '20)"
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-t-sdk-examplecreate-a-basket-from-an-assetwinter20-.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-sdk-examplecreate-a-basket-from-an-assetwinter20-.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 41cffa41d4a71bb827e817901adfa39a06a2c7c618a87a530bce8457cf9ad7d5
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# SDK Example: Create a Basket from an Asset (Winter '20)

Use the example SDK code in this topic to create a basket from an existing asset.

```nolang
// Instantiate the input object for assetToBasket to specify parameters
const input = digitalCommerce.createAssetToBasketInput();
input.catalogCode = "Phones"; // use your Catalog Code
input.basketAction = "assetToBasket";
input.isLoggedIn = true;
input.canCreateBasket = false; // optional - default is false
input.context = '{"accountId":"YOUR ACCOUNT ID", "contractId":"YOUR CONTRACT ID"}';
input.validatePrice = true; // optional - default is true
input.validateAction = true; // optional - default is true
input.rootAssetIds = "02i4P000009ion5QAA,02i4P000009ion6QAA";
input.requestDateTime = "2019-08-10T00:00:000z"; // date or date time in UTC format.

// Invoke assetToBasket API via method assetToBasket()
digitalCommerce
  .assetToBasket(input)
  .then(response => {
    Logger.info(
      "Vlocity digital commerce assetToBasket: " + JSON.stringify(response)
    );
  })
  .catch(error => {
    Logger.info("assetToBasket apexrest call failed" + error);
 });
```

Possible error conditions:

"AssetToBasketInput::getAPIPath() must have catalogCode."

"AssetToBasketInput::getAPIPath() must have context."

"AssetToBasketInput::getAPIPath() must have set isLoggedIn=true."

"AssetToBasketInput::getRequestPayload() must have rootAssetIds."

"AssetToBasketInput::getRequestPayload() must have basketAction."

"AssetToBasketInput::getRequestPayload() must have valid requestDateTime input."
