Clear that List using the API v4

Last fall, Alex explained how to Clear Contacts From Lists in v3 of the API. You now have the same ability in v4 API using the clearLists function. All you need to do is specify the list id returned from the addLists or readLists function. After you call clearLists, all your contacts will be removed from the list, however, they will remain in Bronto.

Here is a sample SOAP message that would clear two lists.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v4="http://api.bronto.com/v4"> <soapenv:Header> <v4:sessionHeader> <sessionId>b058d5e0-7cb4-4578-b16f-a4c049079207</sessionId> </v4:sessionHeader> </soapenv:Header> <soapenv:Body> <v4:clearLists> <list> <id>0bbb03ec0000000000000000000000038e93</id> </list> <list> <id>0bbb03ec00000000000000000000000390d0</id> </list> </v4:clearLists> </soapenv:Body> </soapenv:Envelope>

This PHP script would create a SOAP message like this.

<?php
/**
 * This example will clear two lists of all contacts on those lists.
 * You must edit the code to refer to the list id you wish to clear.
 */

$client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
setlocale(LC_ALL, 'en_US');

try {
        $token = "#####API TOKEN###########";

        print "logging in<br>";
        $sessionId = $client->login(array('apiToken' => $token))->return;

        $session_header = new SoapHeader("http://api.bronto.com/v4",
                           'sessionHeader', array('sessionId' => $sessionId));
        $client->__setSoapHeaders(array($session_header));

        $ids = array(array('id' => '0bbb03ec0000000000000000000000038e93'),
                   array('id' => '0bbb03ec00000000000000000000000390d0'));

        $res = $client->clearLists($ids)->return;

        if ($res->errors) {
                print "There was a problem clearing your lists:<br>";
                print $res->results[$res->errors[0]]->errorString . "<br>";
        } else {
                print "Lists have been cleared<br>";
        }
} catch (Exception $e) {
        print "uncaught exception\n";
        print_r($e);
}
?>

Now you are able to quickly and easily clear your lists without having to find everyone on the list. We do suggest you exercise caution when using this function, as there is no rewind button. I hope you find this new functionality useful. Let us know if you have any questions.

Andrew Kanes
Support Engineer at Bronto

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>

More information about formatting options

CAPTCHA
Just checking to see if you're a human visitor. We don't like automated spam submissions.