addUser

Adds a new User Account.

addUser

Adds a new User Account.

Top ↑

Syntax

int addUser ( string api_key, int account_id, array user_details );

Parameters

api_key (string)

The key required to access the API. See Getting Started for more information.

account_id (int)

ID of the Account to add the User to.

user_details (array)

An associative array of User details. See remarks below for a description of the values in the user_details array.

Return Value

The new Account User ID.

Examples

$api = new Api($url, 'YOURAPIKEY');
$user_details = array(
    'username'     => 'username_123',
    'password'     => '123456abc',
    'first_name'   => 'First Name',
    'last_name'    => 'Last Name',
    'email'        => 'example@example.com',
    'mobile'       => '0412312312',
    'phone'        => '56565656',
    'fax'          => '57575757',
    'position'     => 'Manager',
    'is_read_only' => true,
    'timezone'     => 'Australia/Brisbane',
    'email_user'   => true,
    'is_confirmed' => true
);
$session_details = $api->invokeMethod('addUser', 123456, $user_details);
{
    "id": 1,
    "method": "addUser",
    "params": [
        "YOURAPIKEY",
        "123456",
        {
            "username"     : "username_123",
            "password"     : "123456abc",
            "first_name"   : "First Name",
            "last_name"    : "Last Name",
            "email"        : "example@example.com",
            "mobile"       : "0412312312",
            "phone"        : "56565656",
            "fax"          : "57575757",
            "position"     : "Manager",
            "is_read_only" : true,
            "timezone"     : "Australia/Brisbane",
            "email_user"   : true,
            "is_confirmed" : true
        }
    ]
}
{
    "id": 1,
    "result": 123456,
    "error": null
}

Remarks

The following table shows the structure of the user_details array.

Key Type Mandatory Default Description
username string Yes Username that is unique within the Account.
password string Yes Password.
first_name string Yes User's first name.
last_name string Yes User's last name.
email string Yes User's email address.
phone string Yes User's phone number.
mobile string No User's mobile number.
fax string No User's fax number.
position string No Title of the User's position.
timezone string No API User's timezone User's timezone in tz database format (area/location). For example, Australia/Brisbane. See getTimezoneList.
is_confirmed bool No false Value indicating whether the email address of this User has been confirmed.
is_read_only bool No false Value indicating if the User is able to modify the Account.
receives_promotional bool No true Whether the User has opted to receive promotional messages.
email_user bool No false Send an email to the User with their login details.

Error Codes

This method may return the following error codes in addition to the standard error codes:

Code Error Description
317 Invalid email address specified Email address does not exist or is misspelled.
321 Administrative access denied Account owner or Account of the new Account User is not under your own Account.
322 Username unavailable Username is a duplicate or reserved word.

See Also