Service: CreateAccount

The CreateAccount service allows an agency to create a new sub-account. The created account is return by the service response.

Service Details

SOAP Action: CreateAccount
SOAP Return Object: CreateAccountResp

Input

The following table describes the parameters used for calling the CreateAccount service.

Table: instance of CreateAccountReq

Parameter Mandatory Type Description
header Y APIRequestHeader Header for authentication
accountType Y AccountType An instance of account

Output

The following table describes the parameters returned from the CreateAccount service.

Table: instance of CreateAccountResp

Parameter Mandatory Type Description
header / APIResponseHeader Header containing authentication information
errorCode / Integer Numerical value of the error
errorMessage / String Short literal description of the error
accountType / AccountType The created account

Table: response codes of CreateAccountResp.

0 No error
220 Authentication error, see header object for detailed information
221 AccountType->name is mandatory
222 AccountType->surname is mandatory
223 AccountType->username is mandatory
224 AccountType->password is mandatory
225 AccountType->emailAddress is mandatory
226 AccountType->language is mandatory
227 AccountType->defaultCampaignSenderFromName is mandatory
228 AccountType->defaultCampaignSenderEmailAddress is mandatory
229 AccountType->defaultCampaignReplyEmailAddress is mandatory
230 Maximum amount of available accounts reached
240 Username too short
241 Username not available
242 Password too short
244 AccountType->emailAddress invalid email address
245 AccountType->defaultCampaignSenderEmailAddress invalid email address
246 AccountType->defaultCampaignReplyEmailAddress invalid email address
247 Invalid language value
250 Insufficient credits
251 Insufficient preview credits

Example

Create a new account for John Doe. Only grant access to the reports section.

<?php

// create header object
$header = new stdClass();
$header->userId = USER_ID;
$header->userToken = USER_TOKEN;

// create account object
$account = new stdClass();
$account->name = "John";
$account->surname = "Doe";
$account->username = "JohnDoe21";
$account->password = "JohnsSecretPassword";
$account->company  = "ACME";
$account->website = "http://www.acme.com";
$account->address = "";
$account->zipCity = "";
$account->phone = "";
$account->fax = "";
$account->mobile = "";
$account->countryCode = "US";
$account->credits = 2000;
$account->previewCredits = 0;
$account->emailAddress = "john.doe@acme.com";
$account->language = "EN";
$account->defaultCampaignSenderFromName = "John Doe";
$account->defaultCampaignSenderEmailAddress = "john.doe@acme.com";
$account->defaultCampaignReplyEmailAddress = "john.doe@acme.com";
$account->allowProfile = false;
$account->allowSettings = false;
$account->allowContacts = false;
$account->allowMessages = false;
$account->allowCampaigns = false;
$account->allowReports = true;

$request = new stdClass();
$request->header = $header;
$request->accountType = $account;

$response = $SoapClient->__soapCall("CreateAccount", array($request));

if ($response->errorCode == 0) {
	echo "Account created, account user id:" . $response->accountType->userId;
} else {
	echo Account creation failed: " . $response->errorMessage;
}?>