Skip to content
Last updated

GetClients

Obtain the Clients that match passed criteria

Request Parameters

ParameterTypeDescriptionRequired
actionstring"GetClients"Required
limitstartintThe offset for the returned log data (default: 0)Optional
limitnumintThe number of records to return (default: 25)Optional
sortingstringThe direction to sort the results. ASC or DESC. Default: ASCOptional
statusstringOptional desired Client Status. 'Active', 'Inactive', or 'Closed'.Optional
searchstringThe search term to look for at the start of email, firstname, lastname, fullname or companynameOptional
orderbystringThe column to order by. id, firstname, lastname, companyname, email, groupid, datecreated, statusOptional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
totalresultsintThe total number of results available
startnumberintThe starting number for the returned results
numreturnedintThe number of results returned
clientsarrayThe client entries returned

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' => 'GetClients',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'search' => 'example.com',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'GetClients';
$postData = array(
    'search' => 'example.com',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

Example Response JSON

{
    "result": "success",
    "totalresults": 2,
    "startnumber": 0,
    "numreturned": 2,
    "clients": {
        "client": [
            {
                "id": 2,
                "firstname": "Angelica",
                "lastname": "Mohr",
                "companyname": "",
                "email": "[email protected]",
                "datecreated": "2016-01-15",
                "groupid": 0,
                "status": "Active"
            },
            {
                "id": 1,
                "firstname": "Price",
                "lastname": "Beier",
                "companyname": "",
                "email": "[email protected]",
                "datecreated": "2016-01-01",
                "groupid": 0,
                "status": "Active"
            }
        ]
    }
}

Version History

VersionChangelog
1.0Initial Version
8.2Implement new parameter: "orderby".