{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Server Sync","description":"Developer documentation for the WHMCS API — the","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"server-sync","__idx":0},"children":["Server Sync"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Info"},"children":["As of WHMCS 7.8, modules can implement the List Accounts functionality to offer sync functionality to administrative users (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.whmcs.com/Server_Sync_Tool"},"children":["Server Sync Tool"]},")."]}," ","Implementing this functionality into a provisioning module enables WHMCS to compare a list of accounts returned by a remote system against service records stored within WHMCS, and provides admin users with the ability to perform import and sync operations."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"server-sync-tool","__idx":1},"children":["Server Sync Tool ",{"$$mdtype":"Tag","name":"a","attributes":{"id":"product-details-output"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To allow WHMCS to import accounts from a remote system, meta data fields, and a new function must be included in the module files."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"use WHMCS\\Service\\Status;\n\n...\n\nfunction mymodule_MetaData()\n{\n return array(\n     // The display name of the unique identifier to be displayed on the table output\n     'ListAccountsUniqueIdentifierDisplayName' => 'Domain',\n     // The field in the return that matches the unique identifier\n     'ListAccountsUniqueIdentifierField' => 'domain',\n     // The config option indexed field from the _ConfigOptions function that identifies the product on the remote system\n     'ListAccountsProductField' => 'configoption1',\n );\n}\n \nfunction mymodule_ListAccounts(array $params)\n{\n    $accounts = [];\n    try {\n        // Call the remote api to obtain the list of accounts. Use the values provided by\n        // WHMCS in `$params`. (https://developers.whmcs.com/provisioning-modules/module-parameters/)\n        //$data = mymodule_call($params, 'listaccounts');\n        \n        foreach ($data as $account) {\n            $accounts[] = [\n                // The remote accounts email address\n                'email' => 'john@example.net', \n                // The remote accounts username\n                'username' => 'john', \n                // The remote accounts primary domain name\n                'domain' => 'example.net', \n                // This can be one of the above fields or something different.\n                // In this example, the unique identifier is the domain name\n                'uniqueIdentifier' => 'example.net', \n                // The accounts package on the remote server\n                'product' => 'Basic', \n                // The remote accounts primary IP Address\n                'primaryip' => '1.2.3.4', \n                // The remote accounts creation date (Format: Y-m-d H:i:s)\n                'created' => '2019-07-02 13:15:00', \n                // The remote accounts status (Status::ACTIVE or Status::SUSPENDED)\n                'status' => Status::ACTIVE, \n            ];\n        }\n        // When returning the accounts, ensure that you return a success as a boolean\n        // and accounts as an array.\n        return [\n            'success'  => true, // Boolean value\n            'accounts' => $accounts,\n        ];\n    } catch (Exception $e) {\n        return [\n            'success'  => false, // Boolean value\n            'error' => $e->getMessage(),\n        ];\n    }\n}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"parameters","__idx":2},"children":["Parameters ",{"$$mdtype":"Tag","name":"a","attributes":{"id":"meta-data"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A list of ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/provisioning-modules/module-parameters","title":"Module Parameters"},"children":["Module Parameters"]}," passed to this function can be found ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/provisioning-modules/module-parameters","title":"Module Parameters"},"children":["here"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["WHMCS expects the following parameters returned for each account:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Parameter"},"children":["Parameter"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["email"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The remote accounts email address."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["username"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The remote accounts username."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["domain"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The remote accounts primary domain name."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["uniqueIdentifier"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["If one is not provided by the remote server, we recommend setting this to the domain name."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["product"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The accounts package on the remote server."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["primaryip"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The remote accounts primary IP Address."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["created"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The remote accounts creation date. (Format: Y-m-d H:i:s)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["status"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["string"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The remote accounts status. (WHMCS\\Service\\Status::ACTIVE or WHMCS\\Service\\Status::SUSPENDED)"]}]}]}]}]}]},"headings":[{"value":"Server Sync","id":"server-sync","depth":1},{"value":"Server Sync Tool","id":"server-sync-tool","depth":2},{"value":"Parameters","id":"parameters","depth":2}],"frontmatter":{"title":"Server Sync","seo":{"title":"Server Sync"}},"lastModified":"2026-08-03T17:00:42.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/provisioning-modules/server-sync","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}