Work with the purchase list API

The purchase list API allows you to create purchase lists that are accessible only on specific sites, or for account-based shoppers, only on specific sites and/or accounts.

The API also allows you to create purchase lists that are accessible in all contexts, like the purchase lists that are created using the UI.

The following tasks can be performed using the purchase list API. For additional information on working with APIs, refer to the Use the REST APIs.

Create a purchase list with the API

When a shopper creates a purchase list, it is available in all site and account contexts for consumer commerce or account based-commerce, however, you can specify specific sites and/or accounts.

Issue a POST request to /ccstore/v1/purchaseLists. For example:

{
  "name":"Purchase List 1",
  "description":"Purchase List",
  "siteId":"siteUS",
  "accountId":"or-100001",
    "items": [{
    "productId":"Product_18Cxi",
    "catRefId": "Sku_18Dxi",
    "quantityDesired" : 25
  },
{
    "productId":"Product_5Cx",
    "catRefId": "Sku_5Cxy",
    "quantityDesired" : 30
  }
]
}

Update a purchase list with the API

To update a purchase list issue a PUT request in the following format: /ccstore/v1/purchaseLists/{id} where you provide the purchase list ID. For example, you could use the following to update the name or description of the purchase list with the following:

PUT /ccstore/v1/purchaseLists/gl42244

To update a specific purchase list item, use the /ccstore/v1/purchaseLists/{id}/updateItems. The following example removes one of the products:

{
    "items": [{
    "productId":"Product_18Cxi",
    "catRefId": "Sku_18Dxi",
    "quantityDesired" : 25,
    "op": "update"
  },
{
    "productId":"Product_5Cx",
    "catRefId": "Sku_5Cxy",
    "quantityDesired" : 100,
    "op": "delete"

  }
]
}

Delete a purchase list with the API

To remove a purchase list, issue a DELETE request and the ID of the purchase list. For example:

DELETE /ccstore/v1/purchaseLists/gl42244

Once the purchase list has been removed, the shopper will get a confirmation prompt.