Login/Register
Installatron Server
API Documentation

Getting Started with Installatron Server

Introduction

This document describes how to interface with Installatron Server's REST APIs. Examples, for each API, are provided for CLI, curl, and PHP.

See the left sidebar for a complete list of Installatron Server APIs, and at the bottom of the sidebar are a number of appendices with more information about related topics.

Interfacing

There are multiple elements to an API request:

  • HTTP Method

    Installatron APIs use only three HTTP methods:

    1. GET
    2. POST
    3. DELETE

    Check the second line of an API's documentation to find the appropriate HTTP method to call that API.

    Note that in Installatron's APIs:

    • • All views use GET.

    • • All creates, edits, and miscellaneous actions use POST.

    • • All deletes use DELETE.

  • Command

    The command refers to the API you're calling. For example:

    • GET /users - the API to view all or some users.
    • DELETE /backups/{id} - the API to delete a specific backup.

    The commands are also found on the second line of each APIs documentation page.

  • Headers

    Headers carry additional details about the request and the expected response. Most HTTP requests include two or three headers, depending on the specific API. (API calls made over CLI do not use a header.)

    The X-API-Key header is used to authenticate requests to the Installatron REST API. It should be set to the key= or key2= value configured in /usr/local/installatron/etc/settings.ini. (See the Authentication section below.)

    X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}

    Most Installatron REST API endpoints require an Accept header set to "application/json", indicating that the API response is expected to be formatted in JSON:

    Accept: application/json

    All Installatron REST API endpoints also support the X-HTTP-Method-Override header, which overrides the HTTP method (e.g., "POST", "GET", "DELETE") in environments where certain methods might be restricted or unsupported, by tunneling the desired method through a standard POST request:

    X-HTTP-Method-Override: GET

    The Content-Type header specifies the format of the data in the body of an HTTP request. Installatron REST API endpoints typically expect this to be "application/json", indicating that the request body is JSON-formatted. Alternatively, "application/x-www-form-urlencoded" is also supported for key-value pair data, but using JSON is recommended:

    Content-Type: application/json

    See the examples on each APIs documentation page for use of these headers.

  • Parameters

    These are the values that customize the API call.

    For example, here are some parameters, and example values, for the POST /browser/{id}/install API:

    "user": "exampleuser",
    "url": "https://www.website.com/blog",
    "login": "admin123",
    "passwd": "password123",
    "title": "My Blog"

    See each API page for a full list of available parameters and details on their use.

All Elements Together

When you bring all these elements together your API request looks like this for CLI:

/usr/local/installatron/installatron \
    --POST /browser/wordpress/install \
    --user exampleuser \
    --url https://www.website.com/blog \
    --login admin123 \
    --passwd password123 \
    --title My Blog

Like this for curl:

curl -X POST https://{SERVER_IP}/browser/wordpress/install \
    -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '
        {
            "user": "exampleuser",
            "url": "https://www.website.com/blog",
            "login": "admin123",
            "passwd": "password123",
            "title": "My Blog"
        }
       '

And for PHP:

<?php

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_URL => "https://{SERVER_IP}/browser/wordpress/install",
    CURLOPT_HTTPHEADER => [
        "X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}",
        "Accept: application/json",
        "Content-Type: application/json"
    ],
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POSTFIELDS => json_encode(
        [
            'user' => 'exampleuser',
            'url' => 'https://www.website.com/blog',
            'login' => 'admin123',
            'passwd' => 'password123',
            'title' => 'My Blog'
        ]
    )
]);
if (( $response = curl_exec($ch) )=== false )
{
    trigger_error(curl_error($ch));
}
curl_close($ch);
var_export(json_decode($response, true));

?>

Authentication

Installatron Server's APIs all require authentication. Authentication is provided by either a login to CLI, for the CLI API, or by an "X-API-KEY" header parameter for the curl and PHP APIs.

    CLI Authentication

    Your login to CLI is the authentication for Installatron CLI API calls. You must be logged into CLI as the server's root user to access the Installatron APIs.

    curl Authentication

    curl authentication for Installatron Server API calls is provided by adding this header to your API call:

    -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}'

    Tip: During installation of Installatron Server it generates an IS licensing key which you can find, after installation, in this file:

    /usr/local/installatron/etc/settings.ini

    PHP Authentication

    PHP authentication for Installatron Server API calls is provided by this header line:

    X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}

    Tip: During installation of Installatron Server it generates an IS licensing key which you can find, after installation, in this file:

    /usr/local/installatron/etc/settings.ini

Parameters

Some APIs don't require any parameters (eg. /tasks) but most APIs have some mix of optional and/or required parameters which configure the API call.

For example, here are some parameters for the POST /browser/{id}/install API:

'user' => 'exampleruser',
'url' => 'https://www.website.com/blog',
'login' => 'admin123',
'passwd' => 'password123',
'title' => 'My Blog'

See each API page for a full list of available parameters and details on their use.

The format used by the parameters depends on the method used to call the API:

  • CLI

    For a CLI call to an Installatron Server API the parameters follow directly after the --cmd {command}, and are in the form:

    --{method} {command} \

    The earlier example parameters therefore becomes this in their final CLI form:

    /usr/local/installatron/installatron \
        --POST /browser/wordpress/install \
        --user exampleuser \
        --url https://www.website.com/blog \
        --login admin123 \
        --passwd password123 \
        --title My Blog
  • curl

    For a curl call to an Installatron Server API the parameters are provided with the -d configuration parameter, formatted as a JSON package.

    The earlier example parameters therefore becomes this in their final curl form:

    curl -X POST https://{SERVER_IP}/browser/wordpress/install \
        -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}' \
        -H 'Accept: application/json' \
        -H 'Content-Type: application/json' \
        -d '
            {
                "user": "exampleuser",
                "url": "https://www.website.com/blog",
                "login": "admin123",
                "passwd": "password123",
                "title": "My Blog"
            }
           '
  • PHP

    For a PHP call to an Installatron Server API the parameters are provided with the CURLOPT_POSTFIELDS => option, formatted as a URL-encoded JSON package.

    PHP has a function to automatically format JSON from a PHP array so the earlier example parameters become this in their final PHP form:

    <?php
    
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_URL => "https://{SERVER_IP}/browser/wordpress/install",
        CURLOPT_HTTPHEADER => [
            "X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}",
            "Accept: application/json",
            "Content-Type: application/json"
        ],
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POSTFIELDS => json_encode(
            [
                'user' => 'exampleuser',
                'url' => 'https://www.website.com/blog',
                'login' => 'admin123',
                'passwd' => 'password123',
                'title' => 'My Blog'
            ]
        )
    ]);
    if (( $response = curl_exec($ch) )=== false )
    {
        trigger_error(curl_error($ch));
    }
    curl_close($ch);
    var_export(json_decode($response, true));
    
    ?>

Response

The response from all APIs, and via all methods, is a JSON structure of this general form if the result is a single value:

{
    "result": true,
    "status": 200,
    "errcode": null,
    "data": "the response value"
}

Or if the response is a JSON object then the format will be:


{
    "result": true,
    "status": 200,
    "errcode": null,
    "data":{
            // the main body of the response
        }
}

Or if the response is an array of JSON objects then the format will be:

{
    "result": true,
    "status": 200,
    "errcode": null,
    "total_count": 3,
    "has_more": false,
    "data":[
        {
            // the body of the first item
        },
        {
            // the body of the second item
        },
        {
            // the body of the third item
        }
    ]
}

Detailing the structure of each API's response is left to each API page but we can briefly look at the other top-level values:

  • result

    A boolean ("true" or "false") that tells you whether the task was successful.

  • status

    Installatron utilizes standard HTTP response codes to signify the success or failure of an API request.

    In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed due to the information provided (e.g. a required parameter was omitted, etc.). Codes in the 5xx range indicate an error with Installatron's processing of the request.

    Status codeDescription
    200Successful
    400Bad Request
    403Forbidden
    404Resource not found
    500Internal Error

    This status value is a mirror of HTTP status code value that is found in the header of all responses from the server. It is included here for convenience.

    More specific HTTP codes associated with each API are found in the Response section of each API's documentation.

  • errcode

    Most APIs will return an Installatron error code (errcode) with a more precise explanation for failure, when failure occurs.

    For example, here are the possible errcodes returned by the POST /browser/{id}/install API:

    status code 400
    ---------------
    empty_argument_bkloc
    empty_argument_user
    invalid_argument_content
    invalid_argument_email
    invalid_argument_language
    invalid_argument_login
    invalid_argument_passwd
    invalid_argument_sitetagline
    invalid_argument_sitetitle
    invalid_argument_version
    invalid_argument_{id}
    invalid_argument_application
    invalid_argument_autobk_custom_daily
    invalid_argument_autobk_custom_weekly
    invalid_argument_autobk_custom_monthly
    invalid_argument_autobk_schedule
    invalid_argument_bkloc
    invalid_argument_url
    invalid_argument_url_alreadyexists
    invalid_argument_url_rootonly
    invalid_argument_version
    invalid_argument_version_unmetrequirements
    
    status code 403
    ---------------
    invalid_api_key
    invalid_argument_user
    
    status code 500
    ---------------
    failed_database_create
    failed_filesystem_permission

    Each API's possible http response codes are detailed on each API's page, in their Response sections.

  • errfield

    If the error defined by the errcode value refers to a field value then the internal ID of that field will be included here.

    A field, in Installatron parlance, is an input presented to the user when performing a task. For example, when installing an application the login (the administrator's username to use for the new application), passwd (the password that goes with the login), and the administrative user's email address are all fields that are common to most applications. The list of fields an application uses varies from application to application and can be found using the GET /browser/{id} API.

  • message

    A generic message from Installatron.

    This should not be used to determine success or failure of the API call: instead, use result, status, and errcode.

  • total_count

    When the API returns an array in the data[] portion of the response (eg. /browser), total_count will show the number of entries in the full result set.

  • has_more

    When the API returns an array in the data[] portion of the response (eg. /browser), has_more is "true" when the last entry shown in the response is not the last entry in the full result set.

  • data or data[]

    data can be one of three types:

Error Handling

The Response from all APIs, for all methods, is a JSON package that includes:

  • result
    A boolean tells you whether Installatron thought the API task was successful.
  • status
    A mirror of the standard HTTP response code.
  • errfield
    When a UI field is involved, this will be the internal ID of the field in error.
  • message
    This value should not be used to determine success or failure for the API call, but it can give a text description of a problem when it occurs.

The first three of these values are used to handle errors from Installatron's API calls.

Next Steps

Step 1. Add Users

Now that you've seen how the Installatron Server APIs work your next step is to add users to the Installatron Server database. This is achieved using the POST /users API.

For example, to add a single user to the database, named "useraccountname":

curl -X POST https://{SERVER_IP}/users \
    -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '
        {
            "id": "accountname",
            "parent": "root",
            "type": "user",
            "locale": "en",
            "email": "address@website.com",
            "websites": [
                {
                    "path": "ftps://exampleuser:examplepassword@website.com",
                    "vhosts": {
                        "http://website.com": "public_html",
                        "http://www.website.com": "public_html"
                    }
                },
                {
                    "path": "sftp://exampleusr:examplepwd@website2.com/var/www/vhosts/website2.com",
                    "vhosts": {
                        "http://website2.com": "httpdocs",
                        "http://www.website2.com": "httpdocs",
                        "http://subdomain.website2.com": "httpdocs/subdomain",
                        "https://subdomain.website2.com": "httpdocs/subdomain"
                    }
                }
            ]
        }
       '

The webspace and FTP login referenced in this example must already be provisioned and be working -- for the above example user, this would mean that if we loaded "http://website.com" into a web browser we expect it to load the files found at:

ftps://exampleuser:examplepassword@website.com/public_html

If "http://website.com" does not resolve through a public DNS query then you must define vhost_ip and give it the IP address for website.com.

Step 2. Install WordPress

The next step is to install a test instance of WordPress to one of the user's domains using the POST /browser/{id}/install API:

curl -X POST https://{SERVER_IP}/browser/wordpress/install \
    -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '
        {
            "user": "useraccountname",
            "url": "https://website.com/blog",
            "login": "admin123",
            "passwd": "password123",
            "title": "My Blog"
        }
       '

This example will install "WordPress" to the URL of "https://website.com/blog/" of the user "useraccountname". It will give an administrative username of "admin123", password of "password123", and the site a title of "My Blog".

And then you could load https://website.com/blog (for this example) into a web browser to confirm that the new WordPress website is working.

Step 3. Modify the User

If the user's domain situation changes -- for example, to add a second subdomain -- then you must let Installatron Server know about the change using the using the POST /users/{id} API:

curl -X POST https://{SERVER_IP}/users/useraccountname \
    -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}' \
    -H 'Accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '
        {
            "websites": [
                {
                    "path": "ftps://exampleuser:examplepassword@website.com",
                    "vhosts": {
                        "http://website.com": "public_html",
                        "http://www.website.com": "public_html"
                    }
                },
                {
                    "path": "sftp://exampleusr:examplepwd@website2.com/var/www/vhosts/website2.com",
                    "vhosts": {
                        "http://website2.com": "httpdocs",
                        "http://www.website2.com": "httpdocs",
                        "http://subdomain.website2.com": "httpdocs/subdomain",
                        "https://subdomain.website2.com": "httpdocs/subdomain"
                    }
                },
                {
                    "path": "ssh://exampleusr:examplepwd@website3.com/home/useraccountname",
                    "vhosts": {
                        "http://website3.com": "domains/website3.com/public_html",
                        "https://website3.com": "domains/website3.com/private_html",
                        "http://www.website3.com": "domains/website3.com/public_html",
                        "https://www.website3.com": "domains/website3.com/private_html"
                    }
                }
            ]
        }
       '

Step 4. Sending a User to the GUI

While the Admin Installatron user can log into the Installatron Server GUI through the login prompt at https://{SERVER_IP}, all other users are sent to the GUI using the GET /users/{id}/login API:

curl -X POST https://{SERVER_IP}/users/useraccountname/login \
    -H 'X-API-KEY: {the key= or key2= value from /usr/local/installatron/etc/settings.ini}' \
    -H 'Accept: application/json'

The response from this API call is a JSON package of the following form:

{
    "result": true,
    "status": 200,
    "errcode": null,
    "message": "The task is complete.\n",
    "data": "https://ip-123-123-123-123.is.direct/RMXIft8-8HExkSXbTooEvg"
}

You can then forward the user to the URL in data.

Conclusion

The Installatron Server API v2 gives you control over absolutely every aspect of Installatron. We recommend quickly browsing through each API page to get a sense of the commands that are available, but then you can come back to the pages when you have particular needs.

If you have any questions or comments about the APIs or this documentation please feel free to contact us via Installatron Tickets.

- The Installatron Team




© 2004 - 2025 Installatron LLC. All rights reserved. Privacy Policy.