0

I'm trying to remove all subscribers from a suppression list, I have been able to get one in particular to be deleted, but I have not been able to do it for all of them. How could it be done? Thanks in advance

    var req = api.retrieve("List", 
    ["ListName", "ID"],
    {
        Property: "ListName",
        SimpleOperator: "equals",
        Value: "MySuppressionList"
    }
);

var listId = req.Results[0].ID;

var res = api.updateItem("Subscriber", {
    SubscriberKey: "XXXXXXXXXX",
    EmailAddress: "XXXXXXXXXXX",
    Lists: [
        {
            ID: listId,
            Action: "delete"
        }
    ]
});

1 Answer 1

0

You need to use deleteItem function to remove a subscriber from the specified list, thus here is the script that will do the job -

<script runat = "server">
    Platform.Load("Core", "1");
    var api = new Script.Util.WSProxy();

    var req = api.retrieve("List", 
        ["ListName", "ID"],
        {
            Property: "ListName",
            SimpleOperator: "equals",
            Value: "xxx"
        }
    );
    var listId = req.Results[0].ID;

    var res = api.deleteItem("Subscriber", {
        SubscriberKey: "xxx",
        EmailAddress: "xxx",
        Lists: [
            {
                ID: listId
            }
        ]
    });
</script>
2
  • Thanks for the answer! But, how could i delete all the subscribers of a list? Thank you!
    – MRT
    Commented Jun 17, 2022 at 9:35
  • Then, it will be a totally different script that will retrieve all subscribers within the list and, based on the number of subscribers, iterate through all of them and delete them one by one with the same deleteItem function.
    – Niko
    Commented Jun 17, 2022 at 13:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .