### Get Clients Products Example Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getclientsproducts.md This example demonstrates the structure of the JSON response when retrieving a client's products. It includes details for each product, such as its ID, name, group, domain, server information, and billing cycle. ```APIDOC ## Get Clients Products ### Description Retrieves a list of products and services for a given client. ### Method GET ### Endpoint /path/to/getclientsproducts ### Parameters #### Query Parameters - **clientid** (int) - Required - The ID of the client whose products are to be retrieved. - **limitnum** (int) - Optional - The maximum number of results to return. - **startnum** (int) - Optional - The starting number for the results. - **pid** (int) - Optional - Filter results by product ID. - **serviceid** (int) - Optional - Filter results by service ID. ### Response #### Success Response (200) - **result** (string) - Indicates the success of the operation ('success' or 'error'). - **clientid** (string) - The ID of the client. - **products** (object) - Contains a list of products. - **product** (array) - An array of product objects. - **id** (string) - The unique identifier for the product. - **qty** (string) - The quantity of the product. - **clientid** (string) - The ID of the client owning the product. - **orderid** (string) - The ID of the order associated with the product. - **pid** (string) - The product ID. - **regdate** (string) - The date the product was registered. - **name** (string) - The name of the product. - **groupname** (string) - The name of the product group. - **domain** (string) - The domain associated with the product. - **serverid** (string) - The ID of the server hosting the product. - **servername** (string) - The name of the server. - **serverip** (string) - The IP address of the server. - **serverhostname** (string) - The hostname of the server. - **firstpaymentamount** (string) - The amount of the first payment. - **recurringamount** (string) - The recurring amount for the product. - **paymentmethod** (string) - The payment method used. - **billingcycle** (string) - The billing cycle (e.g., Monthly, Annually). - **nextduedate** (string) - The next due date for the payment. - **status** (string) - The current status of the product (e.g., Active, Terminated). - **username** (string) - The username for accessing the product. - **password** (string) - The password for accessing the product. - **customfields** (object) - Custom fields associated with the product. - **configoptions** (object) - Configuration options for the product. ### Response Example ```json { "result": "success", "clientid": "1", "products": { "product": [ { "id": "1", "qty": "1", "clientid": "1", "orderid": "1", "pid": "1", "regdate": "2015-01-01", "name": "Starter", "groupname": "Shared Hosting", "domain": "demodomain.com", "serverid": "1", "servername": "Saturn", "serverip": "1.2.3.4", "serverhostname": "saturn.example.com", "firstpaymentamount": "12.95", "recurringamount": "12.95", "paymentmethod": "authorize", "billingcycle": "Monthly", "nextduedate": "2016-11-25", "status": "Terminated", "username": "demodoma", "password": "xxxxxxxx", "customfields": {}, "configoptions": {} }, { "id": "2", "qty": "2", "clientid": "1", "orderid": "2", "pid": "3", "regdate": "2015-05-20", "name": "Plus", "groupname": "Shared Hosting", "domain": "demodomain2.net", "serverid": "2", "servername": "Pluto", "serverip": "2.3.4.5", "serverhostname": "pluto.example.com", "firstpaymentamount": "24.95", "recurringamount": "24.95", "paymentmethod": "paypal", "billingcycle": "Monthly", "nextduedate": "2017-01-20", "status": "Active", "username": "demodom2", "password": "xxxxxxxx", "customfields": {}, "configoptions": { "configoption": [ { "id": "1", "option": "Sample Config Option", "type": "dropdown", "value": "Selected option value" } ] } } ] } } ``` ``` -------------------------------- ### Example Response JSON Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/starttasktimer.md This is an example of a successful JSON response when starting a task timer. ```json { "result": "success", "message": "Start Timer Has Been Set" } ``` -------------------------------- ### Example WHMCS Details Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/whmcsdetails.md This is an example of the JSON response you can expect when successfully retrieving WHMCS installation details using the WhmcsDetails API action. ```json { "result": "success", "whmcs": { "version": "8.0.0", "canonicalversion": "8.0.0-release.1" } } ``` -------------------------------- ### Get To-Do Items via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/gettodoitems.md This example demonstrates how to fetch to-do items using the local WHMCS API function. It's suitable for use within your WHMCS installation. The 'status' parameter is optional for filtering. ```php $command = 'GetToDoItems'; $postData = array( 'status' => 'Incomplete', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Add Product via CURL Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/addproduct.md Use this example to add a new product to your WHMCS installation using a CURL request. Ensure you replace placeholder credentials and configure product details as needed. ```bash $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' => 'AddProduct', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'type' => 'other', 'gid' => '1', 'name' => 'Sample Product', 'welcomeemail' => '5', 'paytype' => 'recurring', 'pricing' => array(1 => array('monthly' => 1.00, 'msetupfee' => 1.99, 'quarterly' => 2.00, 'qsetupfee' => 1.99, 'semiannually' => 3.00, 'ssetupfee' => 1.99, 'annually' => 4.00, 'asetupfee' => 1.99, 'biennially' => 5.00, 'bsetupfee' => 1.99, 'triennially' => 6.00, 'tsetupfee' => 1.99)), 'recommendations' => array(array('id' => 1, 'order' => 0), array('id' => 2, 'order' => 1)), 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); ``` -------------------------------- ### GetProducts via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getproducts.md This example demonstrates how to retrieve product configurations using the local API function. It's suitable for use within your WHMCS installation. The 'pid' parameter can be used to specify a particular product. ```php $command = 'GetProducts'; $postData = array( 'pid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Get Affiliates via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getaffiliates.md This example demonstrates how to call the GetAffiliates function locally within your WHMCS installation. For WHMCS 7.2 and later, the admin username is optional. ```php $command = 'GetAffiliates'; $postData = array( ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example theme.yaml Configuration Source: https://github.com/whmcs/developer-docs/blob/master/themes/theme-parameters.md This example demonstrates the basic structure and parameters for a theme.yaml file, including name, description, author, parent theme, and asset dependencies/provides. ```yaml name: "Example" description: "My Company's Branding" author: "Hosting Company, L.L.C." config: parent: twenty-one dependencies: bootstrap: 4.5.2 provides: jquery: 1.12 fontawesome: 5 ``` -------------------------------- ### Get WHOIS Info via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/domaingetwhoisinfo.md This example demonstrates how to retrieve WHOIS information for a domain using the local API function. It's suitable for use within your WHMCS installation. ```php $command = 'DomainGetWhoisInfo'; $postData = array( 'domainid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example Response JSON Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getconfigurationvalue.md This is an example of a successful JSON response when retrieving a configuration value. ```json { "result": "success", "setting": "SystemURL", "value": "http:\/\/www.example.com\/whmcs\/" } ``` -------------------------------- ### Example: HelloWorld Class Definition Source: https://github.com/whmcs/developer-docs/blob/master/modules/module-class-autoloading.md This is an example of a class file that would be placed in the `lib` directory of a module. It defines the `HelloWorld` class with a `printHello` method. ```php namespace WHMCS\Module\Addon\SampleAddonModule; /** * Hello World Class * * @copyright Copyright (c) * @license http://www.whmcs.com/license/ WHMCS Eula */ class HelloWorld { /** * Print hello world. */ public function printHello() { print 'Hello World'; } } ``` -------------------------------- ### Get Configuration Value via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getconfigurationvalue.md This example demonstrates how to retrieve a configuration value using the WHMCS Local API function. This method is suitable for use within your WHMCS installation's PHP files. ```php $command = 'GetConfigurationValue'; $postData = array( 'setting' => 'SystemURL', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Get Domain Lock Status via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/domaingetlockingstatus.md This example demonstrates how to call the DomainGetLockingStatus function using the local API within your WHMCS installation. It's suitable for use within WHMCS modules or templates. ```php $command = 'DomainGetLockingStatus'; $postData = array( 'domainid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Local API Example Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/modulecustom.md Example of how to use the ModuleCustom action via the local API. ```APIDOC ```php $command = 'ModuleCustom'; $postData = array( 'serviceid' => '1', 'func_name' => 'reboot', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` ``` -------------------------------- ### Provisioning Module Core Functions (PHP) Source: https://context7.com/whmcs/developer-docs/llms.txt Implement these functions to manage the lifecycle of server resources. Each function must return 'success' or an error string. Requires server setup. ```php 'My Provider', 'APIVersion' => '1.1', 'RequiresServer' => true]; } function myprovider_ConfigOptions() { return [ 'Package' => ['Type' => 'dropdown', 'Options' => 'starter,pro,enterprise', 'Description' => 'The hosting package to provision'], ]; } function myprovider_CreateAccount($params) { $username = $params['username']; $password = $params['password']; $domain = $params['domain']; $package = $params['configoptions']['Package']; $serverIp = $params['serverip']; try { // Call external API to create the hosting account $response = json_decode(file_get_contents( "https://{$serverIp}/api/create?user={$username}&domain={$domain}&pkg={$package}" ), true); logModuleCall('myprovider', 'CreateAccount', ['username' => $username, 'domain' => $domain, 'package' => $package], $response, $response, [$password]); if ($response['status'] === 'ok') { return 'success'; } return 'Error: ' . $response['message']; } catch ( Exception $e) { return 'Connection failed: ' . $e->getMessage(); } } function myprovider_SuspendAccount($params) { /* return 'success' or error string */ } function myprovider_UnsuspendAccount($params) { /* return 'success' or error string */ } function myprovider_TerminateAccount($params) { /* return 'success' or error string */ } function myprovider_ChangePassword($params) { /* return 'success' or error string */ } ``` -------------------------------- ### Get Emails via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getemails.md This example demonstrates how to call the GetEmails function using the local API within your WHMCS installation. It's suitable for use within WHMCS modules or templates. Authentication is handled differently than external API calls. ```php $command = 'GetEmails'; $postData = array( 'clientid' => '1', 'subject' => 'elcom', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example JSON Response for Module Configuration Parameters Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getmoduleconfigurationparameters.md This is an example of the JSON response you can expect when successfully retrieving module configuration parameters. It lists various settings for a module. ```json { "result": "success", "parameters[0][name]": "FriendlyName", "parameters[0][displayName]": "FriendlyName", "parameters[0][fieldType]": "text", "parameters[1][name]": "email", "parameters[1][displayName]": "PayPal Email", "parameters[1][fieldType]": "text", "parameters[2][name]": "forceonetime", "parameters[2][displayName]": "Force One Time Payments", "parameters[2][fieldType]": "yesno", "parameters[3][name]": "forcesubscriptions", "parameters[3][displayName]": "Force Subscriptions", "parameters[3][fieldType]": "yesno", "parameters[4][name]": "requireshipping", "parameters[4][displayName]": "Require Shipping Address", "parameters[4][fieldType]": "yesno", "parameters[5][name]": "overrideaddress", "parameters[5][displayName]": "Client Address Matching", "parameters[5][fieldType]": "yesno", "parameters[6][name]": "apiusername", "parameters[6][displayName]": "API Username", "parameters[6][fieldType]": "text", "parameters[7][name]": "apipassword", "parameters[7][displayName]": "API Password", "parameters[7][fieldType]": "text", "parameters[8][name]": "apisignature", "parameters[8][displayName]": "API Signature", "parameters[8][fieldType]": "text", "parameters[9][name]": "sandbox", "parameters[9][displayName]": "Sandbox Mode", "parameters[9][fieldType]": "yesno" } ``` -------------------------------- ### Example Get Quotes API Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getquotes.md This is an example of the JSON response returned by the Get Quotes API. It includes details for two quotes, one with associated client information and another without. ```json { "result": "success", "totalresults": 2, "startnumber": 0, "numreturned": 2, "quotes": { "quote": [ { "id": 2, "subject": "", "stage": "Draft", "validuntil": "2023-01-30", "userid": 1, "client": { "id": 1, "firstname": "Richard", "lastname": "Example", "companyname": "Example Inc.", "email": "amalia@example.com", "datecreated": "2022-12-30", "groupid": 0, "status": "Active" }, "firstname": "", "lastname": "", "companyname": "", "email": "", "address1": "", "address2": "", "city": "", "state": "", "postcode": "", "country": "US", "phonenumber": "", "tax_id": "", "currency": 1, "subtotal": "15.86", "tax1": "0.00", "tax2": "0.00", "total": "15.86", "proposal": "", "customernotes": "", "adminnotes": "", "datecreated": "2022-12-30", "lastmodified": "2022-12-30", "datesent": "0000-00-00", "dateaccepted": "0000-00-00", "items": { "item": [ { "id": 1, "description": "Apple", "quantity": "1", "unitprice": "1.23", "discount": "0.00", "taxable": 1 }, { "id": 2, "description": "Pear", "quantity": "3", "unitprice": "5.00", "discount": "2.50", "taxable": 0 } ] } }, { "id": 1, "subject": "", "stage": "Draft", "validuntil": "2023-01-29", "userid": 0, "client": null, "firstname": "William", "lastname": "Smith", "companyname": "", "email": "", "address1": "", "address2": "", "city": "", "state": "", "postcode": "", "country": "US", "phonenumber": "", "tax_id": "", "currency": 1, "subtotal": "0.00", "tax1": "0.00", "tax2": "0.00", "total": "0.00", "proposal": "", "customernotes": "", "adminnotes": "", "datecreated": "2022-12-29", "lastmodified": "2022-12-30", "datesent": "0000-00-00", "dateaccepted": "0000-00-00", "items": { "item": [] } } ] } } ``` -------------------------------- ### Example Response JSON Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/updateclientaddon.md This is an example of a successful JSON response when updating a client addon. ```json { "result": "success", "id": "1" } ``` -------------------------------- ### Example MetaData Function Source: https://github.com/whmcs/developer-docs/blob/master/provisioning-modules/meta-data-params.md Implement this function within your provisioning module to define its meta data configuration parameters. This function should return an associative array containing the parameter names and their corresponding values. ```php function mymodule_MetaData() { return array( 'DisplayName' => 'myModule', 'APIVersion' => '1.1', 'DefaultNonSSLPort' => '1234', 'DefaultSSLPort' => '4321', 'ServiceSingleSignOnLabel' => 'Login to myModule Client', 'AdminSingleSignOnLabel' => 'Login to myModule Admin', 'ListAccountsUniqueIdentifierDisplayName' => 'Domain', 'ListAccountsUniqueIdentifierField' => 'domain', 'ListAccountsProductField' => 'configoption1', ); } ``` -------------------------------- ### Example: Using HelloWorld Class in Module Output Source: https://github.com/whmcs/developer-docs/blob/master/modules/module-class-autoloading.md This example shows how to use the `HelloWorld` class within a module's output function. It imports the class and calls its `printHello` method. ```php use WHMCS\Module\Addon\SampleAddonModule\HelloWorld; // Other code goes here... function sample_addon_module_output() { $hello = new HelloWorld(); $hello->printHello(); } ``` -------------------------------- ### Example GetActivityLog Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getactivitylog.md This is an example of a successful JSON response from the GetActivityLog API call, showing the result, total number of results, starting number, and the activity log entries. ```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 } ] } } ``` -------------------------------- ### Example Request (Local API) Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/addclient.md This example shows how to add a client using the local API function within WHMCS. ```APIDOC ## Example Request (Local API) ```php $command = 'AddClient'; $postData = array( 'firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john.doe@example.com', 'address1' => '123 Main Street', 'city' => 'Anytown', 'state' => 'State', 'postcode' => '12345', 'country' => 'US', 'phonenumber' => '800-555-1234', 'password2' => 'password', 'clientip' => '1.2.3.4', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` ``` -------------------------------- ### Example Get Orders API Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getorders.md This JSON object represents a successful response from the Get Orders API, detailing a single order with its associated line items and fraud detection data. ```json { "result": "success", "totalresults": 1, "startnumber": 0, "numreturned": 1, "orders": { "order": [ { "id": 1, "ordernum": 7858259149, "userid": 1, "contactid": 0, "requestor_id": 1, "admin_requestor_id": 0, "date": "2020-09-23 13:59:35", "nameservers": "", "transfersecret": "", "renewals": "", "renewalsByType": { "domains": [], "services": [], "addons": [] }, "promocode": "", "promotype": "", "promovalue": "", "orderdata": "}", "amount": "8.00", "paymentmethod": "stripe", "invoiceid": 1, "status": "Active", "ipaddress": "123.456.789.110", "fraudmodule": "fraudlabs", "fraudoutput": "{\"is_country_match\":\"Y\",\"is_high_risk_country\":\"N\",\"distance_in_km\":484.990000000000009094947017729282379150390625,\"distance_in_mile\":301.3600000000000136424205265939235687255859375,\"ip_country\":\"US\",\"ip_continent\":\"North America\",\"ip_region\":\"Texas\",\"ip_city\":\"Houston\",\"ip_latitude\":\"29.8284\",\"ip_longitude\":\"-95.4696\",\"ip_timezone\":\"-04:00\",\"ip_elevation\":\"104\",\"ip_domain\":\"whmcs.com\",\"ip_mobile_mnc\":\"NA\",\"ip_mobile_mcc\":\"NA\",\"ip_mobile_brand\":\"NA\",\"ip_netspeed\":\"DSL\",\"ip_isp_name\":\"WHMCS\",\"ip_usage_type\":\"Commercial\",\"is_free_email\":\"Y\",\"is_new_domain_name\":\"N\",\"is_domain_exists\":\"Y\",\"is_proxy_ip_address\":\"N\",\"is_bin_found\":\"NA\",\"is_bin_country_match\":\"NA\",\"is_bin_name_match\":\"NA\",\"is_bin_phone_match\":\"NA\",\"is_bin_prepaid\":\"NA\",\"is_address_ship_forward\":\"N\",\"is_bill_ship_city_match\":\"Y\",\"is_bill_ship_state_match\":\"Y\",\"is_bill_ship_country_match\":\"Y\",\"is_bill_ship_postal_match\":\"Y\",\"is_ship_address_blacklist\":\"N\",\"is_phone_blacklist\":\"N\",\"is_ip_blacklist\":\"N\",\"is_email_blacklist\":\"N\",\"is_credit_card_blacklist\":\"NA\",\"is_device_blacklist\":\"NA\",\"is_user_blacklist\":\"NA\",\"is_high_risk_username\":\"NA\",\"is_export_controlled_country\":\"NA\",\"is_malware_exploit\":\"NA\",\"user_order_id\":\"7858259149\",\"user_order_memo\":\"\",\"fraudlabspro_score\":14,\"fraudlabspro_distribution\":\"57\",\"fraudlabspro_status\":\"APPROVE\",\"fraudlabspro_id\":\"20200923-SAMPLE\",\"fraudlabspro_version\":\"1.5.1\",\"fraudlabspro_error_code\":\"\",\"fraudlabspro_message\":\"\",\"fraudlabspro_credits\":496,\"http_response_code\":200}", "notes": "Sample Notes!", "paymentmethodname": "Stripe", "paymentstatus": "Paid", "name": "WHMCS Tester", "currencyprefix": "$", "currencysuffix": "USD", "frauddata": "", "validationdata": "", "lineitems": { "lineitem": [ { "type": "product", "relid": 1, "producttype": "Other Product\/Service", "product": "SSL Certificates - Rapid SSL", "domain": "sampledomain.com", "billingcycle": "One-Time", "amount": "8.00", "status": "Active" } ] } } ] } } ``` -------------------------------- ### Example Get Stats API Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getstats.md This JSON object represents a successful response from the Get Stats API, detailing various metrics such as income, order counts, ticket statuses, and timeline data. ```json { "result": "success", "income_today": "$5.95 USD", "income_thismonth": "$101.45 USD", "income_thisyear": "$485.21 USD", "income_alltime": "$2485.25 USD", "orders_pending": 7, "orders_today_cancelled": 1, "orders_today_pending": 2, "orders_today_fraud": 1, "orders_today_active": 4, "orders_today_total": 8, "orders_yesterday_cancelled": 1, "orders_yesterday_pending": 2, "orders_yesterday_fraud": 0, "orders_yesterday_active": 2, "orders_yesterday_total": 4, "orders_thismonth_total": 18, "orders_thisyear_total": 124, "tickets_allactive": 60, "tickets_awaitingreply": 5, "tickets_flaggedtickets": 3, "tickets_open": 3, "tickets_answered": 25, "tickets_customerreply": 2, "tickets_closed": 245, "tickets_onhold": 30, "tickets_inprogress": 0, "cancellations_pending": 1, "todoitems_due": 5, "networkissues_open": 0, "billableitems_uninvoiced": 1, "quotes_valid": 2, "staff_online": 1, "timeline_data": { "new_orders": { "2018-11-30": 8, "2018-11-29": 4, "2018-11-28": 3, "2018-11-27": 5, "2018-11-26": 7, "2018-11-25": 9, "2018-11-24": 2 }, "accepted_orders": { "2018-11-30": 4, "2018-11-29": 2, "2018-11-28": 3, "2018-11-27": 4, "2018-11-26": 5, "2018-11-25": 8, "2018-11-24": 2 }, "income": { "2018-11-30": "5.95", "2018-11-29": "10.17", "2018-11-28": "15.30", "2018-11-27": "18.90", "2018-11-26": "17.45", "2018-11-25": "10.28", "2018-11-24": "5.18" }, "expenditure": { "2018-11-30": "0.00", "2018-11-29": "0.00", "2018-11-28": "0.00", "2018-11-27": "0.00", "2018-11-26": "0.00", "2018-11-25": "0.00", "2018-11-24": "0.00" }, "new_tickets": { "2018-11-30": 5, "2018-11-29": 7, "2018-11-28": 10, "2018-11-27": 8, "2018-11-26": 4, "2018-11-25": 9, "2018-11-24": 12 } } } ``` -------------------------------- ### Example Response JSON Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/addclient.md This is an example of a successful JSON response when adding a client. It indicates the operation's success and provides the new client's ID. ```json { "result": "success", "clientid": "1" } ``` -------------------------------- ### Get WHMCS Details Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/whmcsdetails.md This endpoint retrieves details about the current WHMCS installation, including version information. ```APIDOC ## GET WhmcsDetails ### Description Obtain details pertaining to the current WHMCS installation. ### Method POST ### Endpoint /includes/api.php ### Parameters #### Query Parameters - **action** (string) - Required - "WhmcsDetails" ### Request Example ```json { "action": "WhmcsDetails" } ``` ### Response #### Success Response (200) - **result** (string) - The result of the operation: success or error - **whmcs** (array) - The version details of the current WHMCS installation - **version** (string) - The WHMCS version number - **canonicalversion** (string) - The canonical WHMCS version string #### Response Example ```json { "result": "success", "whmcs": { "version": "8.0.0", "canonicalversion": "8.0.0-release.1" } } ``` ``` -------------------------------- ### Example Response JSON Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/addclient.md This is an example of a successful JSON response when adding a client. ```APIDOC ## Example Response JSON ```json { "result": "success", "clientid": "1" } ``` ``` -------------------------------- ### Get WHMCS Installation Details via cURL Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/whmcsdetails.md Use this cURL command to make a POST request to the WHMCS API endpoint to retrieve details about the current WHMCS installation. Ensure you replace placeholder credentials with your actual username and password. ```bash $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' => 'WhmcsDetails', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); ``` -------------------------------- ### Example GetClientsAddons Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getclientsaddons.md This is a sample JSON response for the GetClientsAddons API call, illustrating the structure and fields returned for client product addons. ```json { "result": "success", "serviceid": "", "clientid": "1", "totalresults": "1", "addons[addon][0][id]": "1", "addons[addon][0][qty]": "1", "addons[addon][0][userid]": "1", "addons[addon][0][orderid]": "0", "addons[addon][0][serviceid]": "1", "addons[addon][0][addonid]": "0", "addons[addon][0][name]": "Addon 1", "addons[addon][0][setupfee]": "0.00", "addons[addon][0][recurring]": "15.00", "addons[addon][0][billingcycle]": "Monthly", "addons[addon][0][tax]": "", "addons[addon][0][status]": "Active", "addons[addon][0][regdate]": "2015-12-03", "addons[addon][0][nextduedate]": "2016-10-03", "addons[addon][0][nextinvoicedate]": "2016-10-03", "addons[addon][0][paymentmethod]": "paypal", "addons[addon][0][paymentmethodname]": "PayPal", "addons[addon][0][notes]": "" } ``` -------------------------------- ### Get Email Templates via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getemailtemplates.md Execute the GetEmailTemplates command locally within your WHMCS installation. This method is suitable for server-side scripting. ```php $command = 'GetEmailTemplates'; $postData = array( 'type' => 'general', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Module Create Source: https://github.com/whmcs/developer-docs/blob/master/api/api-index.md Creates a new product for a client. ```APIDOC ## POST /api/v1/products/create ### Description Creates a new product for a client. ### Method POST ### Endpoint /api/v1/products/create ### Request Body - **clientId** (int) - Required - The ID of the client. - **productId** (int) - Required - The ID of the product. - **domain** (string) - Optional - The domain for the product. - **password** (string) - Optional - The password for the product. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. ``` -------------------------------- ### Define Product Configuration Options Source: https://github.com/whmcs/developer-docs/blob/master/provisioning-modules/config-options.md Use this function to define all configurable options for a product. Supports text, password, yes/no, dropdown, radio, and textarea field types. Provisioning modules support up to 24 options. ```php function yourmodulename_ConfigOptions() { return [ "username" => [ "FriendlyName" => "UserName", "Type" => "text", # Text Box "Size" => "25", # Defines the Field Width "Description" => "Textbox", "Default" => "Example", ], "password" => [ "FriendlyName" => "Password", "Type" => "password", # Password Field "Size" => "25", # Defines the Field Width "Description" => "Password", "Default" => "Example", ], "usessl" => [ "FriendlyName" => "Enable SSL", "Type" => "yesno", # Yes/No Checkbox "Description" => "Tick to use secure connections", ], "package" => [ "FriendlyName" => "Package Name", "Type" => "dropdown", # Dropdown Choice of Options "Options" => "Starter,Advanced,Ultimate", "Description" => "Sample Dropdown", "Default" => "Advanced", ], "packageWithNVP" => [ "FriendlyName" => "Package Name v2", "Type" => "dropdown", # Dropdown Choice of Options "Options" => [ 'package1' => 'Starter', 'package2' => 'Advanced', 'package3' => 'Ultimate', ], "Description" => "Sample Dropdown", "Default" => "package2", ], "disk" => [ "FriendlyName" => "Disk Space", "Type" => "radio", # Radio Selection of Options "Options" => "100MB,200MB,300MB", "Description" => "Radio Options Demo", "Default" => "200MB", ], "comments" => [ "FriendlyName" => "Notes", "Type" => "textarea", # Textarea "Rows" => "3", # Number of Rows "Cols" => "50", # Number of Columns "Description" => "Description goes here", "Default" => "Enter notes here", ], ]; } ``` -------------------------------- ### AddonAdd Hook Example Source: https://github.com/whmcs/developer-docs/blob/master/hooks-reference/addon.md Executes when an addon is added to a product or service. Use this hook for any setup or logging required when a new addon is associated with a service. ```php 1.00, 'recurring' => 12.00); }); ``` -------------------------------- ### Get Servers via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getservers.md Execute the GetServers function locally within your WHMCS installation. Provide the command, data, and optionally an admin username for authentication. ```php $command = 'GetServers'; $postData = array( 'serviceId' => '1', 'fetchStatus' => false, ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Get Announcements via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/getannouncements.md Call the GetAnnouncements function directly within your WHMCS installation using the localAPI function. This method is suitable for server-side integrations. ```php $command = 'GetAnnouncements'; $postData = array( ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### ActivateModule via cURL Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/activatemodule.md Use this cURL example to activate a module programmatically. Ensure you replace placeholder credentials and API endpoint with your actual details. The `parameters` array can be adjusted based on the module's configuration requirements. ```bash $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' => 'ActivateModule', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'moduleType' => 'gateway', 'moduleName' => 'paypal', 'parameters' => array('email' => 'billing@example.com', 'forcesubscriptions' => true), 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); ``` -------------------------------- ### Get Domain Nameservers via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/domaingetnameservers.md Execute the DomainGetNameservers action using the local WHMCS API. This method is suitable for use within your WHMCS installation. ```php $command = 'DomainGetNameservers'; $postData = array( 'domainid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example API Response Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/updateproject.md This is a sample JSON response indicating a successful project update operation. ```json { "result": "success", "message": "Project Has Been Updated" } ``` -------------------------------- ### Example Activate Function for Addon Modules Source: https://github.com/whmcs/developer-docs/blob/master/addon-modules/installation-uninstallation.md Implement this function to create custom database tables and schema when your addon module is activated. It returns a status and description message to the user. ```php function addonmodule_activate() { // Create custom tables and schema required by your module try { Capsule::schema() ->create( 'mod_addonexample', function ($table) { /** @var \Illuminate\Database\Schema\Blueprint $table */ $table->increments('id'); $table->text('demo'); } ); return [ // Supported values here include: success, error or info 'status' => 'success', 'description' => 'This is a demo module only. ' . 'In a real module you might report a success or instruct a ' . 'user how to get started with it here.', ]; } catch (\Exception $e) { return [ // Supported values here include: success, error or info 'status' => "error", 'description' => 'Unable to create mod_addonexample: ' . $e->getMessage(), ]; } } ``` -------------------------------- ### Delete Announcement via Local API Source: https://github.com/whmcs/developer-docs/blob/master/api-reference/deleteannouncement.md This example demonstrates how to delete an announcement using the local API function. It's suitable for use within your WHMCS installation. ```php $command = 'DeleteAnnouncement'; $postData = array( 'announcementid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example MetricProvider Function Source: https://github.com/whmcs/developer-docs/blob/master/provisioning-modules/usage-metrics.md This function serves as the entry point for WHMCS to retrieve the MetricProvider instance. It instantiates the MyMetricsProvider class with the provided parameters. ```php use WHMCS\Module\Server\MyModule\MyMetricsProvider; function mymodule_MetricProvider($params) { return new MyMetricProvider($params); } ```