### Example Request (Local API) Source: https://developers.whmcs.com/api-reference/createssotoken Shows how to generate an SSO token using the local WHMCS API function. This method is suitable for use within your WHMCS installation. ```php $command = 'CreateSsoToken'; $postData = array( 'client_id' => '1', 'destination' => 'clientarea:product_details', 'service_id' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### GetProducts via cURL Source: https://developers.whmcs.com/api-reference/getproducts Use this cURL example to make a GET request to the WHMCS API to retrieve product information. 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' => 'GetProducts', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'pid' => '1', 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); ``` -------------------------------- ### Complete Language Override File Source: https://developers.whmcs.com/languages/overrides This example shows a complete language override file containing multiple customized language strings. Ensure the file starts with a PHP tag. ```php '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example theme.yaml Configuration Source: https://developers.whmcs.com/themes/theme-parameters This example demonstrates how to configure a child theme, specifying its name, author, parent theme, and asset dependencies. ```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 ``` -------------------------------- ### Sample Addon Module Output Function Source: https://developers.whmcs.com/modules/module-class-autoloading Demonstrates how to use the 'HelloWorld' class within the main output function of a sample addon module. It instantiates 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(); } ``` -------------------------------- ### Get Clients Addons via Local API Source: https://developers.whmcs.com/api-reference/getclientsaddons This example demonstrates how to call the GetClientsAddons function locally within your WHMCS installation. The admin username is optional for WHMCS 7.2 and later. ```php $command = 'GetClientsAddons'; $postData = array( 'clientid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Get Support Departments via Local API Source: https://developers.whmcs.com/api-reference/getsupportdepartments This example demonstrates how to call the GetSupportDepartments API action directly within your WHMCS installation. The admin username is optional for WHMCS 7.2 and later. ```php $command = 'GetSupportDepartments'; $postData = array( ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example Activate Function for Addon Module Source: https://developers.whmcs.com/addon-modules/installation-uninstallation Use this function to create custom database tables and schema when a module is activated. It returns a status and description message. ```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(), ]; } } ``` -------------------------------- ### Get Cancelled Packages via Local API Source: https://developers.whmcs.com/api-reference/getcancelledpackages This example demonstrates how to call the GetCancelledPackages API function locally within your WHMCS installation. The admin username is optional for WHMCS 7.2 and later. ```php $command = 'GetCancelledPackages'; $postData = array( ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### HelloWorld Class Definition Source: https://developers.whmcs.com/modules/module-class-autoloading Example of a 'HelloWorld' class stored in the 'lib' directory of a sample addon module. It includes 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 Project Details via Local API Source: https://developers.whmcs.com/api-reference/getproject This example demonstrates how to retrieve project information using the local API function within WHMCS. It's suitable for use within your WHMCS installation. ```php $command = 'GetProject'; $postData = array( 'projectid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example Success Response Source: https://developers.whmcs.com/api-reference/setconfigurationvalue This is a sample JSON response indicating a successful modification of a configuration value. ```json { "result": "success", "value_changed": "true" } ``` -------------------------------- ### Get Promotions using Local API Source: https://developers.whmcs.com/api-reference/getpromotions This example demonstrates how to call the GetPromotions action using the WHMCS Local API. It's suitable for use within your WHMCS installation's PHP files. ```php $command = 'GetPromotions'; $postData = array( ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example Success Response Source: https://developers.whmcs.com/api-reference/addprojectmessage This is a sample JSON response indicating that the project message was successfully added. ```json { "result": "success", "message": "Message has been added" } ``` -------------------------------- ### Get Support Statuses via Local API Source: https://developers.whmcs.com/api-reference/getsupportstatuses This example demonstrates how to call the GetSupportStatuses API function directly within your WHMCS installation using the localAPI function. The admin username is optional for WHMCS 7.2 and later. ```php $command = 'GetSupportStatuses'; $postData = array( ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example MetricProvider Class Source: https://developers.whmcs.com/provisioning-modules/usage-metrics Implements the ProviderInterface to define available metrics, retrieve server-wide usage, and fetch usage for a specific tenant. Place this class in modules/servers/mymodule/lib/MyMetricsProvider.php. ```php namespace WHMCS\Module\Server\Mymodule; /** * The above namespace is automatically registered for autoloading classes within * a "lib" sub-directory relative to your module directory. So, place this class * in modules/servers/mymodule/lib/MyMtricsProvider.php. */ use WHMCS\UsageBilling\Contracts\Metrics\MetricInterface; use WHMCS\UsageBilling\Contracts\Metrics\ProviderInterface; use WHMCS\UsageBilling\Metrics\Metric; use WHMCS\UsageBilling\Metrics\Units\Accounts; use WHMCS\UsageBilling\Metrics\Usage; class MyMetricsProvider implements ProviderInterface { private $moduleParams = []; public function __construct($moduleParams) { // A sample `$params` array may be defined as: // // ``` // array( // "server" => true // "serverid" => 1 // "serverip" => "11.111.4.444" // "serverhostname" => "my.testserver.tld" // "serverusername" => "root" // "serverpassword" => "" // "serveraccesshash" => "ZZZZ1111222333444555AAAA" // "serversecure" => true // "serverhttpprefix" => "https" // "serverport" => "77777" // ) // ``` $this->moduleParams = $moduleParams; } public function metrics() { return [ new Metric( 'emailaddr', 'Email Mailboxes', MetricInterface::TYPE_SNAPSHOT, new Accounts('Mailboxes') ), ]; } public function usage() { $serverData = $this->apiCall('stats'); $usage = []; foreach ($serverData as $data) { $usage[$data['username']] = $this->wrapUserData($data); } return $usage; } public function tenantUsage($tenant) { $userData = $this->apiCall('user_stats'); return $this->wrapUserData($userData); } private function wrapUserData($data) { $wrapped = []; foreach ($this->metrics() as $metric) { $key = $metric->systemName(); if ($data[$key]) { $value = $data[$key]; $metric = $metric->withUsage( new Usage($value) ); } $wrapped[] = $metric; } return $wrapped; } private function apiCall($action) { // make remote call with $moduleParams } } ``` -------------------------------- ### Example MetaData Function Source: https://developers.whmcs.com/provisioning-modules/meta-data-params Illustrates how to define a MetaData function to return an associative array of meta data configuration parameters for a provisioning module. ```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', ); } ``` -------------------------------- ### Get Ticket Notes via Local API Source: https://developers.whmcs.com/api-reference/getticketnotes This example demonstrates how to use the Local API function to fetch ticket notes. It's suitable for use within your WHMCS installation. The admin username is optional for WHMCS 7.2 and later. ```php $command = 'GetTicketNotes'; $postData = array( 'ticketid' => '1', ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Get Ticket Attachment Example Source: https://developers.whmcs.com/api-reference/getticketattachment This example demonstrates how to retrieve a ticket attachment using its filename. The response includes the filename and the base64 encoded attachment data. ```APIDOC ## GET /api/v1/websites/developers_whmcs/tickets/{ticketId}/attachments/{attachmentId} ### Description Retrieves a specific ticket attachment. ### Method GET ### Endpoint `/api/v1/websites/developers_whmcs/tickets/{ticketId}/attachments/{attachmentId}` ### Parameters #### Path Parameters - **ticketId** (string) - Required - The ID of the ticket. - **attachmentId** (string) - Required - The ID of the attachment. ### Response #### Success Response (200) - **result** (string) - Indicates the status of the operation ('success' or 'error'). - **filename** (string) - The name of the attachment file. - **data** (string) - The base64 encoded content of the attachment. ### Response Example ```json { "result": "success", "filename": "whmcs_logo.png", "data": "iVBORw0KGgoAAAANSUhEUgAAAPoAAAA+CAYAAAAClQafAAAABGdBTUEAALGOfPtRkwAAAAlwSFlzAAALEwAACxMBAJqcGAAABCVpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IlhNUCBDb3JlIDUuNC4wIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMj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iRCHoFfaL\/HvBT7g4m6DTgBLNEnCdlZtYUyaDWrO35rFrV\/x+xJ\/Aui2sznw8Z2Igctt2qpSK6048aN280uuB9D8O\/B5Z2Q3SN1qjwdRfC6ujozaNCgI0lyNUeqrpvL0EV0pUBkwR7xfvn\/dxRRct+7FeafJWeMvAO5diJeIdHAmQ00t+6tDKcATU\/ytV8KbwsaOGOe09uK38T5tTj0b2BmH7VRSvnaPiorfzE3yeUP7YCDS2yprCzRkzC584kO3GdombL4AWYTmm8va ``` -------------------------------- ### Example MetaData Function Source: https://developers.whmcs.com/domain-registrars/metadata-params Illustrates how to define metadata for a domain registrar module. This function returns an array of configuration parameters. ```php function mymodule_MetaData() { return array( 'DisplayName' => 'myModule', 'APIVersion' => '1.1', 'NonLinearRegistrationPricing' => false, ); } ``` -------------------------------- ### Example String with String Replacements Source: https://developers.whmcs.com/languages/translating Illustrates a language string using '%s' for string replacements. The number and order of '%s' placeholders must be preserved to ensure correct substitution of values. ```php $"_LANG['examplestring'] = \"Honor your house with a server for only %s a year! (%s a month)\"; ``` -------------------------------- ### Get WHMCS Installation Details Source: https://developers.whmcs.com/api-reference/whmcsdetails Use this cURL request to obtain details about your WHMCS installation, including its version. Ensure you replace placeholder credentials with your actual username and password. ```cURL $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 JSON Response for Get Emails Source: https://developers.whmcs.com/api-reference/getemails This is an example of the JSON response structure when successfully retrieving email data. It includes total results, pagination details, and a list of email objects. ```json { "result": "success", "totalresults": 1, "startnumber": 0, "numreturned": 1, "emails": { "email": [ { "id": 16, "userid": 7, "subject": "Five great years with Hosting Company, Inc.!", "message": "
WHMCS

Welcome to WHMCS!

Dear Customer,

Thank you for choosing WHMCS. We are excited to have you on board!

This is a sample email to demonstrate the email content retrieval.

This is a preformatted text block within the email message.

Sincerely,
The WHMCS Team

WHMCS Inc. | 123 Main Street, Anytown, CA 90210

" } ] } } ``` -------------------------------- ### Example Success Response for StartTaskTimer Source: https://developers.whmcs.com/api-reference/starttasktimer This is a sample JSON response indicating a successful execution of the StartTaskTimer API call. ```json { "result": "success", "message": "Start Timer Has Been Set" } ``` -------------------------------- ### Simple Third Party Gateway Link Function Example Source: https://developers.whmcs.com/payment-gateways/third-party-gateway This example demonstrates a `_link` function that returns an HTML form to redirect the user to a payment gateway using POST. It includes basic invoice details. ```php function yourmodulename_link($params) { return '
'; } ``` -------------------------------- ### Get Health Status Source: https://developers.whmcs.com/api-reference/gethealthstatus Use this cURL request to get the health status of your WHMCS installation. You can optionally fetch server status values by setting 'fetchStatus' to true. 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' => 'GetHealthStatus', // See https://developers.whmcs.com/api/authentication 'username' => 'IDENTIFIER_OR_ADMIN_USERNAME', 'password' => 'SECRET_OR_HASHED_PASSWORD', 'fetchStatus' => false, 'responsetype' => 'json', ) ) ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); ``` -------------------------------- ### Update Invoice via Local API Source: https://developers.whmcs.com/api-reference/updateinvoice This example demonstrates how to update an invoice using the Local API function. It's suitable for use within your WHMCS installation. ```php $command = 'UpdateInvoice'; $postData = array( 'invoiceid' => '1', 'status' => 'Unpaid', 'itemdescription' => array(13 => 'Sample Updated Invoice Item'), 'itemamount' => array(13 => 16.95), 'itemtaxed' => array(13 => false), 'newitemdescription' => array(0 => 'New Line Item 1', 1 => 'New Line Item 2'), 'newitemamount' => array(0 => 10.00, 1 => 2.95), 'newitemtaxed' => array(0 => true, 1 => false), 'deletelineids' => array(11, 12), ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ``` -------------------------------- ### Example JSON Response for UpdateClientAddon Source: https://developers.whmcs.com/api-reference/updateclientaddon This is a sample JSON response indicating a successful update of a client addon. ```json { "result": "success", "id": "1" } ``` -------------------------------- ### Example Admin Details Response Source: https://developers.whmcs.com/api-reference/getadmindetails This is a sample JSON response when successfully retrieving administrator details. It includes basic information and permissions. ```json { "result": "success", "adminid": "1", "name": "Site Admin", "notes": "Welcome to WHMCS! Please ensure you have setup the cron job to automate tasks", "signature": "", "allowedpermissions": "Main Homepage,My Account,List Clients,List Services,List Addons,List Domains,Add New Client,Edit Clients Details,Manage Pay Methods,View Clients Products\/Services,Edit Clients Products\/Services,Delete Clients Products\/Services,Perform Server Operations,View Clients Domains,Edit Clients Domains,Delete Clients Domains,View Clients Notes,Add\/Edit Client Notes,Delete Client,Mass Mail,View Cancellation Requests,Manage Affiliates,View Orders,Delete Order,View Order Details,Add New Order,List Transactions,Add Transaction,Edit Transaction,Delete Transaction,View Gateway Log,List Invoices,Create Invoice,Manage Invoice,Delete Invoice,Offline Credit Card Processing,Support Center Overview,Manage Announcements,Manage Knowledgebase,Manage Downloads,List Support Tickets,Open New Ticket,Manage Predefined Replies,View Reports,Addon Modules,Link Tracking,Calendar,To-Do List,WHOIS Lookups,Domain Resolver Checker,View Integration Code,WHM Import Script,Database Status,System Cleanup Operations,View PHP Info,View Activity Log,View Admin Log,View Email Message Log,View Ticket Mail Import Log,View WHOIS Lookup Log,Configure General Settings,Configure Administrators,Configure Admin Roles,Configure Servers,Configure Automation Settings,Configure Payment Gateways,Tax Configuration,View Email Templates,View Products\/Services,Configure Product Addons,View Promotions,Configure Domain Pricing,Configure Support Departments,Configure Spam Control,Configure Banned Emails,Configure Domain Registrars,Configure Fraud Protection,Configure Custom Client Fields,API Access,View Flagged Tickets,Configure Database Backups,Manage Network Issues,Manage Quotes,Configure Currencies,Configure Security Questions,Client Data Export,Mass Data Export,View Billable Items,Manage Billable Items,Configure Client Groups,Refund Invoice Payments,Delete Ticket,View Income Totals,Manage Clients Files,Configure Ticket Statuses,Delete Client Notes,Perform Registrar Operations,Create Upgrade\/Downgrade Orders,Configure Addon Modules,Email Marketer,Configure Product Bundles,View Module Debug Log,View Clients Summary,View Support Ticket,Decrypt Full Credit Card Number,Update\/Delete Stored Credit Card,Create\/Edit Promotions,Delete Promotions,View Banned IPs,Add Banned IP,Unban Banned IP,Create\/Edit Email Templates,Delete Email Templates,Manage Email Template Languages,Create New Products\/Services,Edit Products\/Services,Delete Products\/Services,Manage Product Groups,Allow Login as Owner,Configure Order Statuses,Attempts CC Captures,Generate Due Invoices,Create Predefined Replies,Create Predefined Replies,Delete Predefined Replies,Delete Predefined Replies,Configure Two-Factor Authentication,View Credit Log,Manage Credits,WHMCSConnect,Health and Updates,Configure Application Links,Configure OpenID Connect,Update WHMCS,Modify Update Configuration", "departments": ",1,", "whmcs": { "version": "7.10.2", "canonicalversion": "7.10.2-release.1" } } ``` -------------------------------- ### GetClientsDomains via Local API Source: https://developers.whmcs.com/api-reference/getclientsdomains This example demonstrates how to call the GetClientsDomains function using the WHMCS local API. It's suitable for use within your WHMCS installation. ```php $command = 'GetClientsDomains'; $postData = array( 'clientid' => '1', 'stats' => true, ); $adminUsername = 'ADMIN_USERNAME'; // Optional for WHMCS 7.2 and later $results = localAPI($command, $postData, $adminUsername); print_r($results); ```