API:Add Client

Home / Support / Documentation
From WHMCS Documentation
Jump to: navigation, search

Contents

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 - used to assign the client to a client group
  • securityqid - the ID of the security question for the user
  • securityqans - the answer to the client security question
  • notes
  • cctype - 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

External API

 $postfields["action"] = "addclient"; 
 $postfields["firstname"] = "Test";
 $postfields["lastname"] = "User";
 $postfields["companyname"] = "WHMCS";
 $postfields["email"] = "demo@whmcs.com";
 $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"] = "demo@whmcs.com";
 $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.

API Functions
Client Management
Add Client - Update Client - Delete Client - Close Client - Get Clients
Get Clients Details - Get Clients Products - Get Clients Password - Add Contact - Update Contact
Delete Contact - Update Client Product - Upgrade Product - Validate Login - Send Email
Support Tickets
Get Support Departments - Get Support Statuses - Get Tickets - Get Ticket - Get Ticket Predefined Cats
Get Ticket Predefined Replies - Open Ticket - Reply Ticket - Add Ticket Note - Delete Ticket - Update Ticket
Quotes
Create Quote - Update Quote - Delete Quote - Send Quote - Accept Quote
Module Commands
Module Create - Module Suspend - Module Unsuspend - Module Terminate
Domain Commands
Renew Domain - Get Domain Lock - Get Nameservers - Get WHOIS - Request EPP
Update Lock - Update Nameservers - Update WHOIS - Domain WHOIS Lookup
Order Handling
Get Orders - Get Order Statuses - Add Order - Accept Order - Pending Order - Cancel Order - Fraud Order - Delete Order
Payments/Billing
Get Invoice - Get Payment Methods - Create Invoice - Update Invoice - Add Billable Item - Add Invoice Payment
Add Transaction - Add Credit - Capture Payment
Miscellaneous
Get Activity Log - Get Admin Details - Update Admin Notes - Get Currencies - Get Email Templates
Get To-Do Items - Get To-Do Item Statuses - Get Staff Online - Get Stats - Encrypt Password - Decrypt Password