The addMessageRules function allows you to add Automated Message Rules used to trigger automatic email delivery to groups of contacts.


writeResult = bApi.addMessageRules(messageRuleObject[] messageRules);


Name Type Required Description
name string Yes The name assigned to the Automated Message Rule.
type string Yes The type assigned to the Automated Message Rule: activity (behavioral/activity-based), date (date field-based), recurring (recurring based on a particular date or date range), and api (triggered via an API call).
messageId string Yes The unique id of the Message that will be sent via the Automated Message Rule.

PHP Code Example

 * This script will obtain the ID of a message and then create an
 * automated message rule which sends the message whose ID was
 * previously obtained.
 * @copyright  Copyright (c) 2011 Bronto Software (
$client = new SoapClient('', array('trace' => 1, 
                                 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
try {
  // Add a valid API token
  $token = "ADD API TOKEN HERE";
  print "logging in\n";
  $sessionId = $client->login(array('apiToken' => $token))->return;
  $session_header = new SoapHeader("",
                   array('sessionId' => $sessionId));
  // Obtain the ID of the message you want to 
  // send via the automated message rule.
  // Be sure replace the value with the name of the 
  // message you want to use. 
  $filter = array('name' => array('operator' => 'EqualTo',
                  'value' => 'SOME MESSAGE NAME')
    print "Reading all matching messages\n";
    $messages = $client->readMessages(array('pageNumber' => 1,
                        'includeContent' => false,
                        'filter' => $filter))->return;
    // return is an array of objects found that match the given 
    // filter. If nothing is found, return will be NULL and 0
    // is returned for count(), hence the check for > 0.
    // Ideally, you should make your filter specific enough so 
    // that only the message you want is returned, however, in the
    // event that it is not, we'll get the first item.
    if (count($messages) > 0) {
      print "The message Id is: " . $messages[0]->id . "\n";
    } else {
      exit("Mo messages were found that match the given filter.\n");
  // Add an automated message rule which will send
  // the message whose ID we obtained above. 
  $messageRules = array('name' => 'Example AMR',
                'type' => 'api',
              'messageId' => $messages[0]->id
  print "Adding the automated message rule\n";
  $write_result = $client->addMessageRules(array($messageRules)
  if ($write_result->errors) {
    print "There was a problem adding the automated message rule:\n";
  } else {
    print "The automated message rule has been created.  Id: " . $write_result->results[0]->id . "\n";
} catch (Exception $e) {
  print "uncaught exception\n";