< All Topics

API Basics

SPanel uses a REST API, which relies on POST related requests and JSON formatted responses from the API endpoint.
All API requests are performed on the API endpoint located inside SPanel’s directory.


The API endpoint is dependant on the branding url settings, so the name of the folder is subject to change to ‘hostpanel’ or ‘spanel’ (default) if the owner of the VM enables that feature from the admin interface.


Authentication is performed using an API token generated from the SPanel Admin Interface. The API token is provided with the rest of the request inside the ‘token’ variable. Tokens can be Admin or Client based tokens, depending on how they are generated.

Admin based tokens have access to the functionality available inside the SPanel Admin interface. Requests to the API, which use an admin token should not provide the ‘accountuser’ field.

Client based tokens are generated with a client username and are limited to performing SPanel Client interface actions only for the username with which they are generated. On the time of authentication to the SPanel API, the account username is provided in the ‘accountuser’ field.

tokenstringYesAuth token generated from SPanel Admin Interface
accountuserstringNoAccount user if the token is user-specific


Request calls require 1 additional parameters, ‘action’. It is dependant on the type of the token/user combination and is different for Admin and Client calls. Additional parameters might be required depending on the function executed. More info can be found in each function’s article.

actionstringYesThe category and function being executed
accountuserstringYes/NoThe accountuser parameter is required only when executing user functions. It contains the SPanel user account name to which the function will be performed.


$endpointUrl = '';
$postData = [
  'token' => 'provided_auth_token',
  'accountuser' => 'username',
  'action' => 'accounts/listaccounts',

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $endpointUrl);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
$jsonOutput = curl_exec( $ch );



The above request will provide the following json output:



Output errors always have a standard format, providing an array of error fields with the descriptive text provided for the corresponding issue.

   "result": "error",
         "error1":"Descriptive error message for error1",
         "error2":"Descriptive error message for error2"
Table of Contents