Delete a List

Delete a list along with its contents.


Deletes the List using its lid along with its contents.


swat.deleteList(lid, onSuccess, onError)


Things to consider.

This API deletes all the list contents or products inside the list along with the list, once deleted the list cannot be recovered.


Here's an example of how you can use this API to delete a List called black friday list:

// Define the lid of the list to be deleted
let lid = "59179e9f-139d-4857-bcdd-3ad88a38b47d"; // lid

// Define Success callback 
let onSuccess = function(deletedListObj) {
  // Executed when list is successfully deleted
  console.log(`Successfully deleted the List, ${lid}`, deletedListObj);

// Define error callback 
let onError = function(error) {
  // Error is an xhrObject
  console.log(`Error while deleting the List, ${lid}`, error);

// Delete the List by calling `deleteList function`
swat.deleteList(lid, onSuccess, onError);

To obtain the specific lid for the black friday list you can use the Fetch Lists API to retrieve its lid.

API Parameters

lidguidUnique id of the List to be deleted.
onSuccessfunctionCalled when the List is successfully deleted.
onErrorfunctionCalled when there is an error while deleting the List.

Success Response

The successful response includes details about the removed List, such as its lname, list type, lid, creation and update timestamps, as well as other helpful metadata.

    "di": "e502694b-8f26-4ab3-ae35-bafd7c8eed95", // a unique identifier for the wishlist
    "lty": "wl", // the type of list, in this case a wishlist
    "cts": 1678803432579, // a timestamp for when the wishlist was created
    "cnt": 2, // the number of items in the wishlist
    "lname": "black friday list", // the name of the wishlist
    "cby": null, // the user who created the wishlist, if applicable
    "lid": "9ed33e6b-9720-4ba8-893f-fab72eddbf48", // a unique identifier for the list
    "pid": "/IV7e7cGxT1978LieU1jRdMt6XhYfo=", // unique merchant ID
    "st": 1, // the status of the list or item, in this case 1 means active
    "uts": 1678803432579, // a timestamp for when the item was last updated
    "itemcmnts": 0, // the number of comments on the item
    "uby": null, // the user who last updated the item, if applicable
    "lhash": "bXktd2lzaGxpc3Q=" // a hash or checksum for the list, likely used for data integrity checks

Other References

Things to Consider


Checks before Delete.

Attempting to delete a non-existent list will result in a List Not Found error.

For optimal results, verify the existence of lists using the fetchLists API prior to deleting a list.

Add confirmation pop-up

As this API removes both the list and its contents, it is recommended to incorporate a confirmation popup (e.g., "Are you sure you want to delete?") into your user interface for a better user experience.