whmcs_update_client
Update client information in WHMCS by modifying details like contact data, address, status, or password for existing customers.
Instructions
Update an existing client in WHMCS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientid | Yes | The client ID to update | |
| firstname | No | Client first name | |
| lastname | No | Client last name | |
| No | Client email address | ||
| companyname | No | Company name | |
| address1 | No | Street address | |
| address2 | No | Address line 2 | |
| city | No | City | |
| state | No | State/Province | |
| postcode | No | Postal/ZIP code | |
| country | No | Country (2-letter ISO code) | |
| phonenumber | No | Phone number | |
| password2 | No | New password | |
| status | No | Client status (Active, Inactive, Closed) | |
| credit | No | Credit balance | |
| notes | No | Admin notes | |
| language | No | Client language |
Implementation Reference
- src/whmcs-client.ts:208-234 (handler)Core handler implementation in WhmcsApiClient.updateClient that performs the WHMCS 'UpdateClient' API call with provided parameters.async updateClient(params: { clientid: number; firstname?: string; lastname?: string; companyname?: string; email?: string; address1?: string; address2?: string; city?: string; state?: string; postcode?: string; country?: string; phonenumber?: string; password2?: string; status?: string; credit?: string; taxexempt?: boolean; latefeeoveride?: boolean; overideduenotices?: boolean; separateinvoices?: boolean; disableautocc?: boolean; emailoptout?: boolean; language?: string; notes?: string; }) { return this.call<WhmcsApiResponse & { clientid: number }>('UpdateClient', params); }
- src/index.ts:124-154 (registration)Registers the 'whmcs_update_client' tool with MCP server, including schema validation and thin handler wrapper calling WhmcsApiClient.updateClient.'whmcs_update_client', { title: 'Update Client', description: 'Update an existing client in WHMCS', inputSchema: { clientid: z.number().describe('The client ID to update'), firstname: z.string().optional().describe('Client first name'), lastname: z.string().optional().describe('Client last name'), email: z.string().email().optional().describe('Client email address'), companyname: z.string().optional().describe('Company name'), address1: z.string().optional().describe('Street address'), address2: z.string().optional().describe('Address line 2'), city: z.string().optional().describe('City'), state: z.string().optional().describe('State/Province'), postcode: z.string().optional().describe('Postal/ZIP code'), country: z.string().optional().describe('Country (2-letter ISO code)'), phonenumber: z.string().optional().describe('Phone number'), password2: z.string().optional().describe('New password'), status: z.string().optional().describe('Client status (Active, Inactive, Closed)'), credit: z.string().optional().describe('Credit balance'), notes: z.string().optional().describe('Admin notes'), language: z.string().optional().describe('Client language'), }, }, async (params) => { const result = await whmcsClient.updateClient(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/index.ts:128-146 (schema)Zod input schema defining parameters and validation for the whmcs_update_client tool.inputSchema: { clientid: z.number().describe('The client ID to update'), firstname: z.string().optional().describe('Client first name'), lastname: z.string().optional().describe('Client last name'), email: z.string().email().optional().describe('Client email address'), companyname: z.string().optional().describe('Company name'), address1: z.string().optional().describe('Street address'), address2: z.string().optional().describe('Address line 2'), city: z.string().optional().describe('City'), state: z.string().optional().describe('State/Province'), postcode: z.string().optional().describe('Postal/ZIP code'), country: z.string().optional().describe('Country (2-letter ISO code)'), phonenumber: z.string().optional().describe('Phone number'), password2: z.string().optional().describe('New password'), status: z.string().optional().describe('Client status (Active, Inactive, Closed)'), credit: z.string().optional().describe('Credit balance'), notes: z.string().optional().describe('Admin notes'), language: z.string().optional().describe('Client language'), },
- src/whmcs-client.ts:29-63 (helper)Generic API call method used by updateClient to send HTTP POST request to WHMCS API endpoint with authentication and error handling.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; }