An API (Application Programming Interface) is a program that allows different applications to communicate with each other to share information and functionalities.
In this sense, our API allows you to manage everything you can do in the Clouding panel. From creating servers from different sources, to archiving/unarchiving, creating snapshots, activating backups, adding firewall rules, etc.
For this tutorial we will use the CURL command but we can also use a client for APIs called HTTPie in its CLI and graphical version. And, in addition, you can use any other API client (PostMan (Linux, Windows, Mac), RapidAPI (Mac), etc.).
Refer to the official Clouding API documentation
We recommend that to follow this article and for more information you consult the official Clouding API documentation for more details.
Here is the section where you can read about archiving and unarchiving your cloud server.
You will have an endpoint for each action where you will have to indicate the server ID.
To obtain the list of servers where you will get the server ID you can execute the following:
curl -X GET -H "Content-Type: application/json" -H "X-API-KEY: $CLOUDING_APIKEY" https://api.clouding.io/v1/servers
This will show you in JSON format all the servers you have:
...
{
"id": "58XEgdA0JVQ26mA0",
"name": "TutorialAPI",
"hostname": "test",
"vCores": 0.5,
"ramGb": 1,
"flavor": "0.5x1",
"volumeSizeGb": 5,
"image": {
"id": "BJebl0d7zA2WGwQ1",
"name": "Debian 11 (64 Bit)"
},
...
For each action, you will have to use a different endpoint. For example, for archiving:
curl -X POST -H "Content-Type: application/json" -H "X-API-KEY: $CLOUDING_APIKEY" https://api.clouding.io/v1/servers/$ID/archive
Remember to change $CLOUDING_APIKEY and $ID to the correct values.
Launching this command will archive the server, as you will see in your client panel:
And this is the output of the command in JSON format:
{
"id": "LQbN5nvQovrK9Jae",
"status": "inProgress",
"type": "archive",
"startedAt": "2023-02-17T10:20:52.6601832Z",
"completedAt": null,
"resourceId": "58XEgdA0JVQ26mA0",
"resourceType": "server"
}
On the other hand, you can unarchive the server with the following command:
curl -X POST -H "Content-Type: application/json" -H "X-API-KEY: $CLOUDING_APIKEY" https://api.clouding.io/v1/servers/$ID/unarchive
And you will be able to see in your client panel the unarchiving of your server: