Get Invoices
whmcs_get_invoicesRetrieve WHMCS invoices filtered by client ID, status, or date, with pagination and sorting options.
Instructions
Get invoices with optional filtering
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limitstart | No | Starting offset | |
| limitnum | No | Number of results | |
| userid | No | Filter by client ID | |
| status | No | Filter by status | |
| orderby | No | Field to order by | |
| order | No | Sort order |
Implementation Reference
- src/index.ts:258-278 (registration)Registration of the whmcs_get_invoices tool on the MCP server, with schema definition for input parameters (limitstart, limitnum, userid, status, orderby, order). The handler delegates to whmcsClient.getInvoices().
server.registerTool( 'whmcs_get_invoices', { title: 'Get Invoices', description: 'Get invoices with optional filtering', inputSchema: { limitstart: z.number().optional().describe('Starting offset'), limitnum: z.number().optional().describe('Number of results'), userid: z.number().optional().describe('Filter by client ID'), status: z.enum(['Paid', 'Unpaid', 'Cancelled', 'Refunded', 'Collections', 'Draft', 'Overdue']).optional().describe('Filter by status'), orderby: z.string().optional().describe('Field to order by'), order: z.enum(['asc', 'desc']).optional().describe('Sort order'), }, }, async (params) => { const result = await whmcsClient.getInvoices(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } ); - src/whmcs-client.ts:410-449 (handler)The getInvoices method on WhmcsApiClient that actually calls the WHMCS API with action 'GetInvoices'. It defines the full response type including invoice fields (id, userid, date, duedate, total, status, paymentmethod, etc.).
async getInvoices(params: { limitstart?: number; limitnum?: number; userid?: number; status?: 'Paid' | 'Unpaid' | 'Cancelled' | 'Refunded' | 'Collections' | 'Draft' | 'Overdue'; orderby?: string; order?: 'asc' | 'desc'; } = {}) { return this.call<WhmcsApiResponse & { totalresults: number; startnumber: number; numreturned: number; invoices: { invoice: Array<{ id: number; userid: number; firstname: string; lastname: string; companyname: string; invoicenum: string; date: string; duedate: string; datepaid: string; last_capture_attempt: string; subtotal: string; credit: string; tax: string; tax2: string; total: string; taxrate: string; taxrate2: string; status: string; paymentmethod: string; paymethodid: string | null; notes: string; currencycode: string; currencyprefix: string; currencysuffix: string; }> }; }>('GetInvoices', params); } - src/index.ts:263-270 (schema)Zod schema for the get_invoices tool input validation, defining optional filtering parameters with enums for status and sort order.
inputSchema: { limitstart: z.number().optional().describe('Starting offset'), limitnum: z.number().optional().describe('Number of results'), userid: z.number().optional().describe('Filter by client ID'), status: z.enum(['Paid', 'Unpaid', 'Cancelled', 'Refunded', 'Collections', 'Draft', 'Overdue']).optional().describe('Filter by status'), orderby: z.string().optional().describe('Field to order by'), order: z.enum(['asc', 'desc']).optional().describe('Sort order'), },