whmcs_get_orders
Retrieve WHMCS orders with filtering options for client ID, status, or specific order ID to manage billing data.
Instructions
Get orders with optional filtering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limitstart | No | Starting offset | |
| limitnum | No | Number of results | |
| id | No | Specific order ID | |
| userid | No | Filter by client ID | |
| status | No | Filter by status |
Implementation Reference
- src/index.ts:752-771 (registration)Registers the 'whmcs_get_orders' tool with the MCP server, defining its title, description, input schema using Zod, and a thin handler that delegates to WhmcsApiClient.getOrdersserver.registerTool( 'whmcs_get_orders', { title: 'Get Orders', description: 'Get orders with optional filtering', inputSchema: { limitstart: z.number().optional().describe('Starting offset'), limitnum: z.number().optional().describe('Number of results'), id: z.number().optional().describe('Specific order ID'), userid: z.number().optional().describe('Filter by client ID'), status: z.string().optional().describe('Filter by status'), }, }, async (params) => { const result = await whmcsClient.getOrders(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/whmcs-client.ts:939-989 (handler)Core handler implementation for whmcs_get_orders: the getOrders method in WhmcsApiClient that makes the WHMCS API call to 'GetOrders' action with parameters and returns the typed response containing order details/** * Get orders */ async getOrders(params: { limitstart?: number; limitnum?: number; id?: number; userid?: number; status?: string; } = {}) { return this.call<WhmcsApiResponse & { totalresults: number; startnumber: number; numreturned: number; orders: { order: Array<{ id: number; ordernum: string; userid: number; contactid: number; requestor_id: number; date: string; nameservers: string; transfersecret: string; renewals: string; promocode: string; promotype: string; promovalue: string; orderdata: string; amount: string; paymentmethod: string; invoiceid: number; status: string; ipaddress: string; fraudmodule: string; fraudoutput: string; notes: string; paymentmethodname: string; paymentstatus: string; lineitems: { lineitem: Array<{ type: string; relid: number; producttype: string; product: string; domain: string; billingcycle: string; amount: string; status: string; }> }; }> }; }>('GetOrders', params); }
- src/index.ts:757-763 (schema)Zod input schema definition for the whmcs_get_orders tool parametersinputSchema: { limitstart: z.number().optional().describe('Starting offset'), limitnum: z.number().optional().describe('Number of results'), id: z.number().optional().describe('Specific order ID'), userid: z.number().optional().describe('Filter by client ID'), status: z.string().optional().describe('Filter by status'), },
- src/whmcs-client.ts:29-63 (helper)Generic WHMCS API client method used by getOrders to perform authenticated POST requests to the WHMCS API endpointasync 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; }