Skip to content
Last updated

UpdateContact

Updates a contact with the passed parameters.

Request Parameters

ParameterTypeDescriptionRequired
actionstring"UpdateContact"Required
contactidintThe id of the contact to updateRequired
firstnamestringOptional
lastnamestringOptional
companynamestringOptional
emailstringOptional
address1stringOptional
address2stringOptional
citystringOptional
statestringOptional
postcodestringOptional
countrystring2 character ISO country codeOptional
phonenumberstringOptional
email_preferences[general]boolShould the client receive general emailsOptional
email_preferences[product]boolShould the client receive product emailsOptional
email_preferences[domain]boolShould the client receive domain emailsOptional
email_preferences[invoice]boolShould the client receive invoice emailsOptional
email_preferences[support]boolShould the client receive support emailsOptional
email_preferences[affiliate]boolShould the client receive affiliate emailsOptional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
contactidintThe contact ID that was updated

Example Request (CURL)

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.example.com/includes/api.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query(
        array(
            'action' => 'UpdateContact',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'contactid' => '1',
            'firstname' => 'John',
            'lastname' => 'Doe',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'UpdateContact';
$postData = array(
    'contactid' => '1',
    'firstname' => 'John',
    'lastname' => 'Doe',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

$results = localAPI($command, $postData, $adminUsername);
print_r($results);

Example Response JSON

{
    "result": "success",
    "contactid": "1"
}

Warning Responses

Warning responses are returned when using API functionality that has been removed or marked as deprecated. We suggest following any recommended actions in the warning to ensure future compatibility.

Possible warning messages include:

  • Sub Accounts are no longer supported. Please use UpdateUser

Error Responses

Possible error condition responses include:

  • Contact ID Not Found
  • Duplicate Email Address
  • You must have at least one email address enabled to receive domain related notifications as required by ICANN. To disable domain notifications, please enable domain notifications for the primary account holder or another contact

Version History

VersionChangelog
1.0Initial Version
7.10Added email preferences parameters
8.0Removed sub-account functionality