API:Add Client

Jump to: navigation, search

Purpose

This command is used to add a new client to your WHMCS system.

Attributes

  • firstname
  • lastname
  • email
  • address1
  • city
  • state
  • postcode
  • country - two letter ISO country code
  • phonenumber
  • password2 - password for the new user account

Optional Attributes

  • companyname - optional
  • address2 - optional
  • currency - the ID of the currency to set the user to
  • clientip - Pass the client IP address
  • language - the language to assign to the client
  • groupid - the client group to assign the client to (use the id from tblclientgroups database table)
  • securityqid - the ID of the security question for the user
  • securityqans - the answer to the client security question
  • notes
  • cardtype - Visa, Mastercard, etc...
  • cardnum
  • expdate - in the format MMYY
  • startdate
  • issuenumber
  • customfields - a base64 encoded serialized array of custom field values
  • noemail - pass as true to surpress the client signup welcome email sending
  • skipvalidation - set true to not validate or check required fields

All client required fields can be optional if "skipvalidation" is passed

Example Command

Custom Fields
In the following examples for the custom fields, it shows the adding of the value 'Google' into your client custom field with the ID '1'.

External API

 $postfields["action"] = "addclient"; 
 $postfields["firstname"] = "Test";
 $postfields["lastname"] = "User";
 $postfields["companyname"] = "WHMCS";
 $postfields["email"] = "[email protected]";
 $postfields["address1"] = "123 Demo Street";
 $postfields["city"] = "Demo";
 $postfields["state"] = "Florida";
 $postfields["postcode"] = "AB123";
 $postfields["country"] = "US";
 $postfields["phonenumber"] = "123456789";
 $postfields["password2"] = "demo";
 $postfields["customfields"] = base64_encode(serialize(array("1"=>"Google")));
 $postfields["currency"] = "1";

Internal API

 $command = "addclient";
 $adminuser = "admin";
 $values["firstname"] = "Test";
 $values["lastname"] = "User";
 $values["companyname"] = "WHMCS";
 $values["email"] = "[email protected]";
 $values["address1"] = "123 Demo Street";
 $values["city"] = "Demo";
 $values["state"] = "Florida";
 $values["postcode"] = "AB123";
 $values["country"] = "US";
 $values["phonenumber"] = "123456789";
 $values["password2"] = "demo";
 $values["customfields"] = base64_encode(serialize(array("1"=>"Google")));
 $values["currency"] = "1";
 
 $results = localAPI($command,$values,$adminuser);

Successful Response

result = success
message =  xxx - returned on error
clientid = returned ID of newly added Client

Error Response

result=error&message= You did not enter your first name# firstname field left blank.
result=error&message= You did not enter your last name# lastname field left blank.
result=error&message= You did not enter your email address# email field left blank.
result=error&message=The email address you entered was not valid # Invalid email address
result=error&message= You did not enter your email address# email field left blank.
result=error&message= You did not enter your  address line 1# address1 field left blank.
result=error&message= You did not enter your city# city field left blank.
result=error&message= You did not enter your state# state field left blank.
result=error&message= You did not enter your postcode# postcode field left blank.
result=error&message= You did not enter your country # country field left blank.
result=error&message= You did not enter your phone number# phonenumber field left blank.
result=error&message= Invalid telephone phone number# Invalid telephone format.