Returns delivery data, or each unsubscribe for all contacts in an account.


The readUnsubscribes function may return one or many unsubscribe objects. See the documentation for unsubscribeObject to view the data that could potentially be returned.


unsubscribeObject[] unsubscribes = bApi.readUnsubscribes(filter unsubscribeFilter, pageNumber);


Name Type Required Comments
filter unsubscribeFilter Yes The filter used to return specific unsubscribe data.
pageNumber int Yes Retrieves the next “batch” of objects as the value specified increases from 1. In order to obtain an entire set of objects for a given call, you should increase the number value assigned to pageNumber until no more objects are returned.

PHP Code Example

 * Returns each unsubscribe for all contacts in an account.
 * You can filter what unsubscribes are returned using the unsubscribeFilter
 * @see ../reference/r_api_soap_unsubscribefilter/
 * @param int $pageNumber
 *   Returns the next batch of objects as you increase the value from 1
 * @param unsubscribeFilter $filter
 *   The filter used to return specific unbsubscribe data
 * @return array An array containing unsubscribe objects
 *  @see ../reference/r_api_soap_general_unsubscribeobject/
 * @copyright  Copyright (c) 2018 Oracle + Bronto
$client = new SoapClient('', array('trace' => 1,
                                 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
try {
  $token = "YOUR_API_KEY";
  print "logging in\n";
  $sessionId = $client->login(array('apiToken' => $token))->return;
  $session_header = new SoapHeader("",
                   array('sessionId' => $sessionId));
  // No filter set
  $filter = array();
  // Example filter by ContactId
  //$filter = array("contactId" => "CONTACT_ID");
  print "reading all lists\n";
  $unsubscribes = $client->readUnsubscribes(array('pageNumber' => 1,'filter' => $filter))->return;
  foreach ($unsubscribes as $unsubscribe) {
    // Print contactId, method, and date unsubscribed
    print "contactId: " . $unsubscribe->contactId . "; method: " . $unsubscribe->method . "; created: " . $unsubscribe->created . "\n";
} catch (Exception $e) {
  print "uncaught exception\n";