---
schema_version: "1"
id: 33fe2e9572be5a699644f1b3eacce0789af938faa8a84f01e85f32ca91c5faa1
title: "SDK Example: Create a Basket from an Asset (Fall '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-assetfall20-.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-t-sdk-examplecreate-a-basket-from-an-assetfall20-.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0ce153a301ceac1d20964cf402f536b3596153b8d54d6eb2707f4a423fecb4d8
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# SDK Example: Create a Basket from an Asset (Fall '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."
