This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

CloudwaysCDN — a powerful solution that offers superior performance and satisfied global audience for your business. Read More

How to Manage Cloudways Server Settings Using Cloudways API

Updated on  25th October

11 Min Read
Reading Time: 11 minutes

Cloudways API is specially designed for developers and re-sellers. The main benefit of the API is that third party users could enjoy all the features of the platform through a purpose built UI.

Manage Server Settings Using Cloudways API Banner

In our series of API articles, we have used the Cloudways API for performing operations, such as purging Varnish cache, application management, cloning Github repository, etc. In this tutorial, I will discuss how to manage your Cloudways server settings using Cloudways API. I’ll use Guzzle PHP HTTP Client for handling the requests.

As a prerequisite for this tutorial, install the Guzzle client. If you are not clear about the process, you should check out Create And Delete Applications Via Cloudways API tutorial.

Create a new file in the root folder to begin the process. Name it as CloudwaysAPIClient.php and paste the following code in it.

This code starts with calling vendor/autoload.php and defines Guzzle built-in classes.

After this, the class CloudwaysAPIClient constructor loads the Guzzle and then prepares the Cloudways API access token. The constructor gets the email and API key and further generates the token using the prepare_access_token() function.

Next, we have the StatusCodeHandling() function for handling most of the status codes generated by the Cloudways API.

Next are the functions that get the server and server settings using Cloudways API. The get_servers() function provides you the necessary server information and the get_servers_settings() function gets you all the server related settings. In these functions, I have bound the access token into the header to get servers and its settings, decode the returned data from JSON and return it to the view file.

The last function of the class is set_servers_settings(). This function updates the data on Cloudways server using a custom UI.

The next step is to create the front view that uses the Cloudways API to manage server settings. Create a new file index.php in the root folder. The code for the index.php is as follows:

In the code above, I first created an object of the API class and then called the related functions to get the server information and settings. I have created a form with several fields to bind the details coming from and going to these functions.

If you paid attention to the code, I included PHPTimezone.php using include 'PHPTimezone.php'; statement. This file is used to implement default PHP timezone capabilities. This file manages the date timezone field of the server.

Create another file PHPTimezone.php in root folder and add the following code to it:

The code is now done. The front view will look like this when the code is executed:

Manage Server Settings


In this tutorial, I used Cloudways API to get and manage server settings. I used Guzzle to perform the actions, created the class to connect to the API and manage the data easily. If you have any questions or would like to suggest an improvement, please leave a comment below.

Share your opinion in the comment section. COMMENT NOW

Fayyaz Khattak

Fayyaz is a Magento Community Manager at Cloudways - A Managed Magento Hosting Platform. His objective is to learn & share about PHP & Magento Development in Community. Fayyaz is a food lover and enjoys driving. You can email him at

Start Growing with Cloudways Today.

Our Clients Love us because we never compromise on these

Get Our Newsletter
Be the first to get the latest updates and tutorials.