The addApiTokens function allows you to add a new API token.


writeResult = bApi.addApiTokens(apiTokenObject[] apiTokens);


Name Type Required Description
name string Yes The name assigned to API token. The name can be used to reference a specific API token when using the apiToken functions.
permissions int Yes The permissions assigned to the API token. An API token can have read, write, and send permissions. Each permission is assigned an int value. To assign:
  • Read = 1
  • Write = 2
  • Read, Write = 3
  • Send = 4
  • Read, Send = 5
  • Send, Write = 6
  • Read, Write, Send = 7
active boolean Yes Whether or not the API token is active. You can always go back and activate or deactivate API tokens at a later time.
accountId boolean Yes The account, referenced by ID, that the API token is assigned to.

PHP Code Example

        * This script will add an API token with read, write, and send
        * permissions. The API token will also be made active.
        * @copyright  Copyright (c) 2011 Bronto Software (
        $client = new SoapClient('', array('trace' => 1, 
        'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
        try {
        // Add your API token 
        $token = "API TOKEN HERE";
        print "logging in\n";
        $sessionId = $client->login(array('apiToken' => $token))->return;
        $session_header = new SoapHeader("",
        array('sessionId' => $sessionId)
        // NOTE the permissions parameter is an int. We use
        // 7 to assign read, write, and send permissions.
        // Replace the accountId place holder with a
        // valid account ID.
        $apiTokenObject = array('name' => 'Example API Token',
        'permissions' => '7',
        'active' => true,
        'accountId' => 'SOME ACCOUNT ID'
        $write_result = $client->addApiTokens(array($apiTokenObject))->return;
        // Note we are accessing the results and errors arrays.
        // Both of these arrays are returned as part of 
        // writeResult object.
        if ($write_result->errors) {
        print "There was a problem adding the account:\n";
        } else {
        print "API Token has been created.  Id: " . $write_result->results[0]->id . "\n";
        } catch (Exception $e) {
        print "uncaught exception\n";