---
title: Fully functional Acronis Cyber Platform API PHP sample – WHMCS provisioning module
description: Discover the Acronis Cyber Cloud WHMCS provisioning module, a fully functional integration available on the WHMCS Marketplace. This PHP-based module showcases Acronis Cyber Platform API usage, serving as a valuable quick start resource for building custom WHMCS modules. Reuse or modify the code under the MIT license to meet your specific needs.
canonical_url: https://www.acronis.com/en/blog/posts/php-api-sample/
locale: en
last_updated: 2026-10-13
---

[Acronis Blog](https://www.acronis.com/en/blog/)
# Fully functional Acronis Cyber Platform API PHP sample – WHMCS provisioning module

Discover the Acronis Cyber Cloud WHMCS provisioning module, a fully functional integration available on the WHMCS Marketplace. This PHP-based module showcases Acronis Cyber Platform API usage, serving as a valuable quick start resource for building custom WHMCS modules. Reuse or modify the code under the MIT license to meet your specific needs.

[Start building now](https://developer.acronis.com/en-us/)

[![Image 2: Marina Smolyanaya](https://staticfiles.acronis.com/images/content/0cf4cad9bb151360286a29a0eabab251.png)](https://www.acronis.com/en/blog/authors/marina-smolyanaya/ "Marina Smolyanaya")

[Marina Smolyanaya,](https://www.acronis.com/en/blog/authors/marina-smolyanaya/)Lead Product Manager

4 min read

Last updated 04 October 2023

The Acronis Cyber Cloud WHMCS provisioning module is a production-quality fully functional WHMCS integration developed by Acronis’ engineering team. The module is also available at the WHMCS Marketplace. It’s a valuable example of Acronis Cyber Platform API usage with PHP and a great quick starter for companies who want to build their own WHMCS module for Acronis Cyber Cloud. A developer can just reuse the code and business logic, or change what they need to change, as we publish it under the MIT license.

## Acronis Cyber Platform PHP Client and Authorization Routine

The client for Acronis Cyber Platform provides rich functionality. The library located at src\includes\acroniscloud\vendor\acronis\ci-lib-php-cloud-client\lib\Api and contains ready-to-reuse advanced functions to work with Tenants, Users, Reports etc. All these advanced workloads use the base implementation of low-level API interactions located at src\includes\acroniscloud\lib\CloudApi.

The basis for API calls is implemented in ApiClient class, while all authorization routines are implemented in AuthorizedApi class. The client implementation is quite straightforward, it wraps HTTP calls into the callApi function which is used to call specific REST API. Let's see how authorization is implemented.

The process starts with the obtainAccessToken function in AuthorizedApi class. It supports 2 types of grant types: password and client credentials. For the password grant type, we directly request IDP API to receive an authorization token. For the client credentials grant type we need to make some additional preparation, see below:

/**

* @param bool $force

* @return string

*/

protected function obtainAccessToken($force = false)

{

return LocalApi::decryptPassword($this->fromCache(function () {

if ($this->getGrantType() === static::GRANT_TYPE_CLIENT_CREDENTIALS) {

$idpToken = $this->fetchClientAccessToken();

} else {

/** @var Token $idpToken */

$idpToken = $this->unauthorizedCall(function () {

return $this->getIdpApi()->postIdpToken(

'password', null, $this->getLogin(), $this->getPassword()

);

});

}

return LocalApi::encryptPassword($idpToken->getAccessToken());

}, $this->getAccessTokenTtl(), true, $this->getCredentialsHash(), $force));

}

And then we call IDP API as well.

private function fetchClientAccessToken()

{

$clientId = $this->getLogin();

$clientSecret = $this->getPassword();

$authCredentials = base64_encode("{$clientId}:$clientSecret");

$this->getApiClient()->getConfig()->addDefaultHeader(

'Authorization',

"Basic {$authCredentials}"

);

$idpToken = $this->unauthorizedCall(function () {

return $this->getIdpApi()->postIdpToken('client_credentials');

});

$this->getApiClient()->getConfig()->deleteDefaultHeader('Authorization');

return $idpToken;

}

Let's check what’s happened inside postIdpToken. You can see that it's just a HTTP POST call to the specific endpoint with all required parameters set.

public function postIdpToken($grant_type, $client_id = null, $username = null, $password = null, $refresh_token = null, $code = null, $scope = null, $assertion = null, $device_code = null, $totp_code = null)

{

// parameters check is removed here for code clearness

....

// parse inputs

$resourcePath = "/idp/token";

$httpBody = '';

$queryParams = [];

$headerParams = [];

$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json']);

if (!is_null($_header_accept)) {

$headerParams['Accept'] = $_header_accept;

}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/x-www-form-urlencoded']);

// params handling is removed here for code clearness

.....

// for model (json/xml)

if (isset($_tempBody)) {

$httpBody = $_tempBody; // $_tempBody is the method argument, if present

} elseif (count($formParams) > 0) {

$httpBody = $formParams; // for HTTP post (form)

}

// make the API Call

try {

list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(

$resourcePath,

'POST',

$queryParams,

$httpBody,

$headerParams,

'\Acronis\Cloud\Client\Model\Idp\Token',

'/idp/token'

);

return new HttpResponse($statusCode, $httpHeader, $this->apiClient->getSerializer()->deserialize($response, '\Acronis\Cloud\Client\Model\Idp\Token', $httpHeader));

} catch (HttpException $e) {

// exceptopn handling is removed here for code clearness

......

}

throw $e;

}

}

Now we understand what class should be used for API calls and how to get an authorization token. Let's look into another API usage example.

## Working with API

All API calls can be found in Api class located in src\includes\acroniscloud\lib\CloudApi\Api.php. It's a wrapper of specific classes from src\includes\acroniscloud\vendor\acronis\ci-lib-php-cloud-client\lib\Api.

For example, for a new tenant creation, the postTenants functions from TenantsApi class should be used.

public function createTenant(TenantPost $body)

{

return $this->authorizedCall(function () use ($body) {

return $this->getTenantsApi()->postTenants($body);

});

}

And the same way as it is implemented for IDP API calls, it's a wrapped POST call to /tenants endpoint with required parameters.

/**

* Operation postTenants

*

* Tenants

*

* @param \Acronis\Cloud\Client\Model\Tenants\TenantPost $body (required)

* @param string $_issues (optional)

* @throws \Acronis\Cloud\Client\ApiException on non-2xx response

* @return HttpResponse

*/

public function postTenants($body, $_issues = null)

{

// parameters check is removed here for code clearness

....

// parse inputs

$resourcePath = "/tenants";

$httpBody = '';

$queryParams = [];

$headerParams = [];

$formParams = [];

$_header_accept = $this->apiClient->selectHeaderAccept(['application/json']);

if (!is_null($_header_accept)) {

$headerParams['Accept'] = $_header_accept;

}

$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json']);

/// params handling is removed here for code clearness

.....

// for model (json/xml)

if (isset($_tempBody)) {

$httpBody = $_tempBody; // $_tempBody is the method argument, if present

} elseif (count($formParams) > 0) {

$httpBody = $formParams; // for HTTP post (form)

}

// this endpoint requires OAuth (access token)

if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {

$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();

}

// make the API Call

try {

list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(

$resourcePath,

'POST',

$queryParams,

$httpBody,

$headerParams,

'\Acronis\Cloud\Client\Model\Tenants\Tenant',

'/tenants'

);

return new HttpResponse($statusCode, $httpHeader, $this->apiClient->getSerializer()->deserialize($response, '\Acronis\Cloud\Client\Model\Tenants\Tenant', $httpHeader));

} catch (HttpException $e) {

// exceptopn handling is removed here for code clearness

......

}

throw $e;

}

}

Now we understand Acronis Cyber Cloud WHMCS provisioning module code structure for the Acronis Cyber Platform integration and can find, learn and reuse valuable code pieces.

If you have any question regarding Acronis Cyber Platform API samples or usage, please check the documentations at Acronis Developer Network portal or use Acronis Cyber Platform Forum.

## Acronis Cyber Cloud WHMCS Integration and Hooks

Acronis Cyber Cloud WHMCS provisioning module uses WHMCS hooks model to integrate. You can find registered hooks in includes\hooks\acroniscloud.php.

$hooks = [

'ServerAdd',

'ServerDelete',

'ServerEdit',

'ClientEdit',

'ProductEdit',

'ServiceDelete',

'AdminAreaHeaderOutput',

'ClientAreaHeaderOutput',

'OrderProductUpgradeOverride',

];

$outputHooks = [

'AdminAreaHeaderOutput',

'ClientAreaHeaderOutput',

];

foreach ($hooks as $hook) {

add_hook($hook, 1, function ($parameters) use ($hook, $outputHooks) {

/** @var Dispatcher $dispatcher */

$response = '';

try {

$dispatcher = Locator::getInstance()->get(DispatcherFactory::NAME);

$response = $dispatcher->dispatch(

__FILE__,

ACRONIS_CLOUD_SERVICE_NAME . RequestInterface::ACTION_NAME_DELIMITER . $hook,

$parameters

);

} catch (Exception $e) {

// always suppress exceptions for hooks not to affect other WHMCS modules

}

return in_array($hook, $outputHooks) ? $response : $parameters;

});

}

And in src\includes\acroniscloud\controllers.php you can find hooks mapping.

'hooks' => new ModuleActionRouter([

'ServerAdd' => [Server::class, 'updateServerInfo'],

'ServerEdit' => [Server::class, 'updateServerInfo'],

'ServerDelete' => [Server::class, 'deleteInternalTag'],

'ClientEdit' => [ContactInfo::class, 'updateTenants'],

'ProductEdit' => [Product::class, 'setupCustomFields'],

'ServiceDelete' => [Subscription::class, 'terminate'],

'OrderProductUpgradeOverride' => [Product::class, 'beforeUpgrade'],

'AdminAreaHeaderOutput' => [Server::class, 'adminOutput'],

'ClientAreaHeaderOutput' => [CustomHeaderOutput::class, 'clientOutput'],

])

Additional information regarding WGMCS integrations development can be found at WHMCS portal for developers.

## Summary

Now you know how to start coding your own Acronis Cyber Platform solution using PHP and Management API.

*   Start today, register on the [Acronis Developer Portal](https://web.archive.org/web/20230329131000mp_/https://developer.acronis.com/) and see the [code samples available](https://web.archive.org/web/20230329131000mp_/https://github.com/acronis)
*   Review solutions available in the Acronis Cyber Cloud Solutions Portal
*   Build you own WHMCS module for Acronis Cyber Cloud

[API](https://www.acronis.com/en/blog/tags/api/)  
[workloads](https://www.acronis.com/en/blog/tags/workloads/)  
[acronis cyber agent](https://www.acronis.com/en/blog/tags/acronis-cyber-agent/)

## Written by

![Image 3: Marina Smolyanaya](https://staticfiles.acronis.com/images/content/0cf4cad9bb151360286a29a0eabab251.png)

Marina Smolyanaya

Lead Product Manager

Marina Smolyanaya leads the Product Management team that is responsible for Platform and Integration technology. With over 10 years in the industry and an extensive cybersecurity background, Marina's goal is to transform Acronis Cyber Protect Cloud into an open platform, drive Acronis Technology Ecosystem through best-in-class integration technology, and empower Acronis partners and third-party vendors to build their application with Acronis. Marina holds an MSc in Management with International Finance from the University of Glasgow and has a BSc in Computer Systems engineering.

[Previous post](https://www.acronis.com/en/blog/posts/getting-started-with-acronis-cyber-platform-api-using-python/)  
[Getting Started with Acronis Cyber Platform API using Python](https://www.acronis.com/en/blog/posts/getting-started-with-acronis-cyber-platform-api-using-python/)

[Next post](https://www.acronis.com/en/blog/posts/optimizing-ui-ux-with-users-management-and-usage-information-acronis-cyberfit-developer-training-part-iii/)  
[Optimizing UI/UX with Usage Information: Acronis #CyberFit Developer Training Part III](https://www.acronis.com/en/blog/posts/optimizing-ui-ux-with-users-management-and-usage-information-acronis-cyberfit-developer-training-part-iii/)

About Acronis

Acronis is a leader in AI-native cyber protection, unifying data protection, cybersecurity, IT operations and hybrid infrastructure to deliver business continuity, security and compliance with less cost and complexity. More than 21,000 service providers trust Acronis to protect over 750,000 businesses in 150 countries. Acronis is headquartered in Schaffhausen, Switzerland.

[Add as a preferred source on Google](https://google.com/preferences/source?q=acronis.com)

## Related stories

Want to learn more? Read the latest stories featuring this solution on our blog.

[Acronis Blog](https://www.acronis.com/en/blog/)

![Image 4: Introducing Ticket Bridge: Simplify your ticketing with Acronis Cyber Platform](https://staticfiles.acronis.com/images/blog-card/d42a8db84245d62cb2deab683032320c.png)

[Introducing Ticket Bridge: Simplify your ticketing with Acronis Cyber Platform](https://www.acronis.com/en/blog/posts/introducing-ticket-bridge-simplify-your-ticketing-with-acronis-cyber-protect-cloud/)

With Ticket Bridge, MSPs can consolidate ticket creation for many products — saving time and increasing operational efficiency.

**June 13, 2025**3 min read

![Image 5: Build with Acronis: An introduction to Acronis CyberApp Standard](https://staticfiles.acronis.com/images/blog-card/5925ce4e8042cfc3492ab1df3d27cede.png)

[Build with Acronis: An introduction to Acronis CyberApp Standard](https://www.acronis.com/en/blog/posts/build-with-acronis-an-introduction-to-acronis-cyberapp-standard/)

Today, we are proud to announce a new chapter in Acronis history with the release of Acronis CyberApp Standard, a unique development framework that provides a fully digital ISV and MSP experience to build an application on the Acronis platform.

**October 20, 2023**6 min read

![Image 6: Acronis #CyberFit Developer Training Part IV: Reports Management & Infrastructure Information](https://staticfiles.acronis.com/images/blog-card/434c6c31b8d009cd399a8a4611ddceac.png)

[Acronis #CyberFit Developer Training Part IV: Reports Management & Infrastructure Information](https://www.acronis.com/en/blog/posts/mastering-reports-management-locations-and-infrastructure-information-acronis-cyberfit-developer-training-part-iv/)

Accelerate your learning journey with our comprehensive courses designed for developers of all levels. Develop high-quality, marketable integrations with ease, regardless of your experience level. In this section, we delve into usage reporting, locations, and infrastructure information for advanced skills.

**October 04, 2023**4 min read
