Invapi API FAQ¶
In this article
Instant Server Ordering Algorithm with eq/order_instance¶
-
Create a client API key;
-
Choose the server location: NL/US/FI/DE/IS/TR/UK/ES/IT/PL/CH (Netherlands, USA, Finland, Germany, Iceland, Turkey, UK, Spain, Italy, Poland, Switzerland);
-
Use the presets/list request to determine the preset ID for deployment.
This ID will later be used as
instance_idorpreset. For example, if"id": 108, the values areinstance_id=108andpreset=108; -
Use the os/list request to determine the
os_idoros_nameof the operating system you want to install, using the instance ID from step 3 or its alias. For example, for Ubuntu 22.04, this value will be returned in the response as"id": 187and"alias": ubuntu. You can also find OS IDs and information on which server types they are available in the list of currently supported OSs;Note
If you do not want to install an OS during deployment, specify
own_os=1later. -
Use the software/list request to identify available software for this instance and get its ID (the
soft_idparameter). For example, for the WordPress CMS, the value in the request output will be"id": 20. You can find a list of installable software and its installation parameters (ID, server type, required RAM and disk space, number of CPU cores, etc.) in the supported software list;Note
You can skip pre-installing software during deployment if you wish to do it manually later.
-
Use the traffic_plans/list request to get the network traffic plan ID for your server. For example, for the
3Tb traffic (1Gbps) VMplan, the call will return"id": 25; -
Obtain a session token
$HOSTKEY_TOKENvia the auth/login request; -
Order the server by inserting the data obtained in steps 2-7 into the eq/order_instance request. You must specify your
rootpassword, the server billing perioddeploy_period(monthly, quarterly, 6 months, or yearly), and whether you want an email notification upon deployment viadeploy_notify(we recommend setting this totrueby default).
Optional additional parameters can be specified as described in the eq/order_instance call.
Below is an example of ordering a server with WordPress (id=20) on Debian 11 (id=108):
Example POST request for instant server ordering, cURL
curl -s "https://invapi.hostkey.com/eq.php" -X POST \
--data "action=order_instance" \
--data "token=eeee51003b1d81d2eca65660735c0531" \
--data "deploy_period=monthly" \
--data "deploy_notify=true" \
--data "preset=108" \
--data "location_name=NL" \
--data "os_id=180" \
--data "soft_id=20" \
--data "traffic_plan=25" \
--data "root_pass=mdLus8Ng" \
Example positive response
Invapi will select/create the corresponding server in the specified location and proceed with deployment. Before any installation, a check for sufficient funds on the credit balance will be performed (if automatic payments from credit balance are enabled) or an invoice will be issued. If the installation is successful, the new server will be linked to the client's account. The client will be notified by email upon request. All paid licenses will be added as order add-ons.
Note
If there is an incompatibility between the selected operating system and the software being installed, you will receive a message like this:
{
"result": -1,
"error": "reinstall: extra software Odoo (#49) is not compatible with Ubuntu 22.04"
}
You will need to select a different operating system (set a different os_id parameter).
Attention
You can start using the server after receiving an email notification that deployment has finished or when the Active status appears in the My Servers section of the Invapi control panel. If a failure occurs during the server deployment process, a notification will be sent to your email. Deployment can take 20 minutes or more.
You can monitor the installation and its status using asynchronous actions.
The installation will be successfully completed when you receive an asynchronous action message like this:
Reinstalling a server via eq/order_instance¶
Reinstalling a server is performed similarly to ordering one; it differs only by passing an additional id parameter in the eq/order_instance request—the ID of the server being reinstalled from Invapi—and not using the preset parameter. During a reinstall, you can choose a different operating system and pre-installed software, or perform a "clean" reinstall by setting the own_os=1 parameter (in which case you must set os_id = 0).
Attention
The location_name parameter is mandatory even during a reinstall. You must specify the current server location (e.g., NL or US), otherwise, the API may return an OS compatibility error.
POST request for reinstallation, cURL
curl -s "https://invapi.hostkey.com/eq.php" -X POST \
--data "action=order_instance" \
--data "token=$HOSTKEY_TOKEN" \
--data "hostname={Hostname}" \
--data "os_id={OS ID}" \
--data "soft_id={Software ID}" \
--data "root_pass={root password}" \
--data "ssh_key={public SSH key}" \
--data "post_install_script=" \
--data "own_os=" \
--data "root_size=100" \
--data "location_name={Server location with specified ID}" \
--data "id={Invapi Server ID}" // Presence of ID triggers the server reinstallation process.
Attention
If you receive a message stating that no server with that ID was found during a reinstall request, refresh the list of servers linked to your session token by calling eq/update_servers.
Note
If there is an incompatibility between the selected operating system and the software being installed, you will receive a message like this:
{
"result": -1,
"error": "reinstall: extra software Odoo (#49) is not compatible with Ubuntu 22.04"
}
You will need to select a different operating system (set a different os_id parameter).
Attention
You cannot start a new reinstallation if the previous process has not finished. Otherwise, you will receive a warning:
For example, suppose we want to reinstall our server from the previous example to Rocky Linux 9 (id=205) and Grafana (id=18). The request would be as follows:
Example POST request for reinstallation, cURL
Example positive response
Attention
When reinstalling using this method, no email notification is sent upon successful completion! You must remember and save the new root password (or use the existing server password), and you can find access information for the installed software in the Marketplace documentation or directly in the server card within the Invapi control panel.
By using this asynchronous key (the callback field), we can track the reinstallation process using asynchronous actions.