Thanks to visit codestin.com
Credit goes to developers.whmcs.com

Skip to content
Last updated

GetActivityLog

Obtain the Activity Log that matches passed criteria

Request Parameters

ParameterTypeDescriptionRequired
actionstring"GetActivityLog"Required
limitstartintThe offset for the returned log data (default: 0)Optional
limitnumintThe number of records to return (default: 25)Optional
clientidintThe ID of the client to obtain the log for.Optional
datestringThe date of the activity log to retrieve in localised format (eg 01/01/2016)Optional
userstringThe client email, user email, or admin username to retrieve the log entries for.Optional
descriptionstringSearch the log for a specific stringOptional
ipaddressstringThe IP Address to search the activity log forOptional

Response Parameters

ParameterTypeDescription
resultstringThe result of the operation: success or error
totalresultsintThe total number of results available
startnumberintThe starting number for the returned results
activityarrayThe activity log 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' => 'GetActivityLog',
            // See https://developers.whmcs.com/api/authentication
            'username' => 'IDENTIFIER_OR_ADMIN_USERNAME',
            'password' => 'SECRET_OR_HASHED_PASSWORD',
            'description' => 'Cron Job',
            'responsetype' => 'json',
        )
    )
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);

Example Request (Local API)

$command = 'GetActivityLog';
$postData = array(
    'description' => 'Cron Job',
);
$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,
    "activity": {
        "entry": [
            {
                "id": 2,
                "clientId": 0,
                "userId": 0,
                "adminId": 1,
                "date": "2021-01-01 06:56:49",
                "description": "Cron Job: Check for Updates: No new updates available",
                "username": "admin",
                "ipaddress": "172.18.0.1",
                "userid": 0
            },
            {
                "id": 1,
                "clientId": 0,
                "userId": 0,
                "adminId": 1,
                "date": "2021-01-01 06:56:49",
                "description": "Cron Job: Perform WHMCS Update Check",
                "username": "admin",
                "ipaddress": "172.18.0.1",
                "userid": 0
            }
        ]
    }
}

Version History

VersionChangelog
1.0Initial Version
8.0Added userId to response. Renamed userid response to clientId. userid may be removed in a future version.
8.5Renamed userid parameter to clientid. Backwards compatibility preserved for userid.