Get Activity Log
whmcs_get_activity_logRetrieve system activity logs from your WHMCS installation with filters for user, date, description, IP, and pagination to monitor and audit actions.
Instructions
Get system activity log
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "whmcs_get_activity_log"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limitstart | No | Starting offset | |
| limitnum | No | Number of results | |
| userid | No | Filter by user ID | |
| date | No | Filter by date | |
| user | No | Filter by user | |
| description | No | Filter by description | |
| ipaddress | No | Filter by IP address |
Implementation Reference
- src/index.ts:1062-1083 (registration)Tool registration for 'whmcs_get_activity_log' with input schema and handler that calls whmcsClient.getActivityLog()
server.registerTool( 'whmcs_get_activity_log', { title: 'Get Activity Log', description: 'Get system activity log', inputSchema: { limitstart: z.number().optional().describe('Starting offset'), limitnum: z.number().optional().describe('Number of results'), userid: z.number().optional().describe('Filter by user ID'), date: z.string().optional().describe('Filter by date'), user: z.string().optional().describe('Filter by user'), description: z.string().optional().describe('Filter by description'), ipaddress: z.string().optional().describe('Filter by IP address'), }, }, async (params) => { const result = await whmcsClient.getActivityLog(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } ); - src/index.ts:1064-1076 (schema)Input schema definition for whmcs_get_activity_log tool with optional filtering parameters
{ title: 'Get Activity Log', description: 'Get system activity log', inputSchema: { limitstart: z.number().optional().describe('Starting offset'), limitnum: z.number().optional().describe('Number of results'), userid: z.number().optional().describe('Filter by user ID'), date: z.string().optional().describe('Filter by date'), user: z.string().optional().describe('Filter by user'), description: z.string().optional().describe('Filter by description'), ipaddress: z.string().optional().describe('Filter by IP address'), }, }, - src/whmcs-client.ts:1247-1272 (handler)The getActivityLog method on WhmcsApiClient that calls the WHMCS 'GetActivityLog' API action with typed parameters and response type
/** * Get activity log */ async getActivityLog(params: { limitstart?: number; limitnum?: number; userid?: number; date?: string; user?: string; description?: string; ipaddress?: string; } = {}) { return this.call<WhmcsApiResponse & { totalresults: number; startnumber: number; numreturned: number; activity: { entry: Array<{ id: number; date: string; user: string; description: string; ipaddress: string; userid: number; }> }; }>('GetActivityLog', params); } - src/whmcs-client.ts:68-92 (helper)Helper method flattenParams used to convert nested parameters into URL-encoded format for API requests
private flattenParams(params: Record<string, unknown>, prefix = ''): Record<string, string> { const result: Record<string, string> = {}; for (const [key, value] of Object.entries(params)) { const newKey = prefix ? `${prefix}[${key}]` : key; if (value === null || value === undefined) { continue; } else if (typeof value === 'object' && !Array.isArray(value)) { Object.assign(result, this.flattenParams(value as Record<string, unknown>, newKey)); } else if (Array.isArray(value)) { value.forEach((item, index) => { if (typeof item === 'object') { Object.assign(result, this.flattenParams(item as Record<string, unknown>, `${newKey}[${index}]`)); } else { result[`${newKey}[${index}]`] = String(item); } }); } else { result[newKey] = String(value); } } return result; } - src/whmcs-client.ts:29-63 (helper)Generic API call helper that sends requests to the WHMCS API endpoint, used by getActivityLog to invoke 'GetActivityLog' action
async call<T extends WhmcsApiResponse>(action: string, params: Record<string, unknown> = {}): Promise<T> { const url = `${this.config.apiUrl.replace(/\/$/, '')}/includes/api.php`; const postData: Record<string, string> = { identifier: this.config.apiIdentifier, secret: this.config.apiSecret, action: action, responsetype: 'json', ...this.flattenParams(params) }; if (this.config.accessKey) { postData.accesskey = this.config.accessKey; } const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(postData).toString(), }); if (!response.ok) { throw new Error(`WHMCS API request failed: ${response.status} ${response.statusText}`); } const data = await response.json() as T; if (data.result === 'error') { throw new Error(`WHMCS API error: ${data.message || 'Unknown error'}`); } return data; }