Skip to content
Last updated

GetUsers

Obtain the Users that match passed criteria

Request Parameters

ParameterTypeDescriptionRequired
actionstring"GetUsers"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
searchstringThe search term to look for at the start of email, firstname, lastname, or fullnameOptional

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

Example Request (Local API)

$command = 'GetUsers';
$postData = array(
    'search' => '[email protected]',
    'responsetype' => 'json',
);
$adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later

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

Example Response JSON

{
    "result": "success",
    "totalresults": 1,
    "startnumber": 0,
    "numreturned": 1,
    "users": [
        {
            "id": 1,
            "firstname": "John",
            "lastname": "Smith",
            "email": "[email protected]",
            "datecreated": "2020-12-15 15:29:49",
            "validationdata": "",
            "clients": [
                {
                    "id": 1,
                    "isOwner": true
                }
            ]
        }
    ]
}

Version History

VersionChangelog
8.1.0Initial Version