function cust.create

Creates a customer account.

Arguments:

argrequired?syntaxinfo
parentIDNposintcustID of account that is to be the parent account for the new customer (defaults to the account you used for the API login)
accountnameYstringlegal trading name for this account. Usually the same as the contact orgname (if it exists) or else the name
contactYarraysub array containing primary contact information
sourceNstringinformation only; where the customer came from (eg "google")
usernameNstringCustomer's username
passwordYstringCustomer's password
secretquestionNstringCustomer's chosen security question
secretanswerNstringAnswer to customer's chosen security question
custofYlist:(company keywords)billcomp list
ok_to_contactNbooleanDefines whether it is OK to send correspondance to the customer; default=1
ok_to_newsletterNbooleanDefines whether it is OK to send newsletters to the customer; default=1

Further argument information

accountname

This field is the main trading name/legal entity for the account. If the customer is a business, this will be the business name. If the customer is opening an account for their own personal use, this field should contain their name.

contact

A sub-array containing contact information. This sub-array is fed into the contact.create function. For a full list of arguments, read the documentation on that function.

You do not need to specify the owner_custID element of this array because the cust.create does this for you.

username

This is the username that a customer will later be able to use to log in to their account. It must be system-unique. If you omit this field, the username will default to matching their account number.

secretquestion

Customers can choose a security question to record against their account. This is useful if they call us up having forgotten their password because we can use the secret question and answer to verify their identity. The question should relate to something that the customer finds easy to remember but is hard for someone else to guess. Avoid questions that have a limited number of possible answers such as a favourite colour, or questions that have yes/no answers.

custof

An array or comma separated list of billcomp (supplier company) keywords. The list should include every supplier group company that is going to supply goods and services to this customer.

For a list of billcomps available, see the billing_companies element returned by the API login process for the parent API account. This contains a list of billcomps. The array is keyed by the billcomp keyword.

ok_to_contact

If this argument is set to true (it is by default) then we may contact the customer directly on occasion. Normally you would set this to 0 (false) if for some reason we were not to do this (eg if someone referred the customer to us but wanted all customer correspondance to go via themselves)

ok_to_newsletter

If this argument is set to true (it is by default) then we may occasionally send promotional newsletters to the customer. If you have a signup form that offers the customer to opt out of receiving newsletters, you may want to set this field to zero if the customer has chosen to opt out.

Example

Create an account for Derby Dumpvalves Ltd and set up the account to work with skycom and centralindex.

Perl example request:

POST https://live.apicontrol.co.uk/1/json
my %args =
  (
    'parentID' => ,
    'accountname' => 'Derby Dumpvalves Ltd',
    'password' => 'wedkjn3439',
    'custof' => 'centralindex,skycom',
    'ok_to_contact' => 1,
    'ok_to_newsletter' => 1,
    'secretquestion' => 'What does your neighbour have in his back garden?',
    'secretanswer' => 'A pink steamroller',
    'contact' =>
      {
        'title' => 'Mr',
        'fname' => 'Fred',
        'lname' => 'Aichison',
        'addr1' => '73 Springforth Road',
        'town' => 'Derby',
        'county' => 'Derbyshire',
        'postcode' => 'D12 8QT',
        'countrycode' => 'UK',
        'phone' => '08451212121',
        'interphone' => '+44.8451212121',
        'phone_times' => 'daytime',
        'fax' => '08452121212',
        'interfax' => '+44.8452121212',
        'fax_times' => '24/7',
        'email' => 'fred@derbydumpvalves.co.uk',
      },
  );

my $res = $api->cust_create(%args);

XML example request:

POST https://live.apicontrol.co.uk/1/json

In this example, the response indicates that the new account ID (custID) is 29929. Because we didn't supply a username, the username has also been set to '29929'.

Perl example response:

{
  'success' => '1',
  'questionID' => '24',
  'errordiags' => '',
  'username' => '29929',
  'numadded' => '1',
  'sc_accountID' => '11100',
  'error' => undef,
  'errornum' => '',
  'custID' => '29929',
  'contactID' => '14549',
  'results' => []
};

XML example response: