Get your free beta license ↗
Documentation · Release 0.2.35

Commands and API reference

UrbeStack is a web hosting control panel for Linux servers. You can perform the same operations through any of its three interfaces and get the same results.

Interfaces

  • Web interface. Administrators, resellers, and customers sign in at https://your-server:8443 and use the administrator’s panel, the reseller’s panel, and the customer’s panel, respectively. This documentation uses 8443, the default port, throughout. You can choose a different port during installation and change it later with the panel.port setting.
  • Commands. Every operation has a command you run as root at the server’s shell. Examples include urbestack-domain-add, urbestack-mail-account-add, and urbestack-cert-issue. There are more than 300 commands, and each prints its usage with --help.
  • REST API. The API provides more than 370 operations for billing systems, scripts, and your own tools. It accepts and returns JSON. Every server has an OpenAPI 3 document describing the API at /usr/local/urbestack/openapi.json.

How the interfaces work together

The web interface accesses the server exclusively through the API. A program can use the API to do anything you can do in the web interface. For every change, the API runs the same command you would run at the server’s shell. When you add a domain from the web interface, a script, or the shell, the same code runs the same checks and produces the same result.

Default API access

On a new server, the API is reachable only from the server itself at http://127.0.0.1:8442/api. The default value of panel.api_local_port is 8442. You can call it from the server’s shell or from scripts running on the server. Requests from the internet to any path under /api/ on port 8443 receive 404. The web interface continues to work because it calls the API from inside the server.

Opening the API

An administrator can open the API from the administrator’s panel. In the “Security” section, open the “Settings” tab and turn on the “API reachable from outside” switch. You can also open it by running this command as root at the server’s shell.

# urbestack-setting-set --key api.public --value true

Once opened, the API is reachable at https://your-server:8443/api. On the same tab, you can limit access by adding IP addresses or networks to the list of “trusted addresses”. When the list contains entries, only requests from those IP addresses or networks can reach the API. Requests from any other IP address receive 403. When the list is empty, any IP address can reach the API.

To close the API to outside requests again, turn off the same switch. Scripts that call the API from outside the server then stop working.

Tokens and scopes

Every API call carries a token in the Authorization: Bearer TOKEN header. You can create a token with this command at the server’s shell.

# urbestack-token-create --user NAME --scopes LIST

You can also obtain a token by sending a user’s name and password to POST /auth/login.

A token belongs to a user and is limited to the operations that user may perform. Its scopes determine which areas of the API it can access. The default scope is read, which allows only read operations. The other scopes are domains, dns, certificates, mail, databases, files, users, backups, settings, security, export, license, and all.

What it covers

Commands are grouped by their first word, operations by what they work on. The two groupings don’t match one to one: mail is 38 commands in one family and 81 operations in one group.

DemoRather look than read?demo.urbestack.com is a fictional server running the panel, open to anyone. Every page of its administrator’s panel shows the command that does the same thing.
Open the demo ↗