This document covers the control panels' APIs. You need to be logged in with the appropriate privileges to call a function.

Authentication methods

Session unique ID authentication

You can use this method when working with a control panel through your web browser.

Follow the link

  https://IP-address/manager/billmgr?out=xml&func=auth&username=user_name&password=password

The control panel will return either an error message or the following XML document:

  
    <?xml version="1.0" encoding="UTF-8"
    ?>
  

    <doc>
  

    <auth id="session id"
    />
  

    </doc>
  

You should specify this session id in the auth parameter to each call to a control panel. The session id is valid during one hour. If you do not send any requests to the control panel during that period, you will have to get authorized again.

  https://IP-address/manager/billmgr?auth=session_id&out=xml&func=function&parameter1=value&parameter2=value...

In the URL above you may use the following internal control panel's names:

  • billmgr - BILLmanager
  • vdsmgr - VDSmanager
  • dsmgr - DSmanager
  • dnsmgr - DNSmanager
  • ipmgr - IPmanager

authinfo authentication

This method can be used for remote function calls. To call a BILLmanager function, you need to add the authinfo parameter and specify a login and password of the user who will call that functions:

  https://IP-address/manager/billmgr?authinfo=admin1:mypasswd&out=xml&func=function&parameter1=value&parameter2=value...

You must send the authinfo parameter with each call to the control panel.

Key authentication

This method allows using the administrator's login or password.

The key is a random line at least 16 symbols long, such as 1234567890qwertyuiop

The username is "John".

A server administrator may use any of the above authentication methods and execute the following request:

https://URL/billmgr?out=xml&func=session.newkey&username=vasya&key=1234567890qwertyuiop

In case of errors an error message will return. If not, the user will be redirected to

https://URL/billmgr?func=auth&username=vasya&key=1234567890qwertyuiop&checkcookie=no

Following the above link will authorize the user and delete the key.

  • You may specify the key from any IP address. After the user is granted access to the control panel, this IP address will be associated with the session.
  • The key can be used only once.
  • Access is allowed from any IP address (even from those that are denied to access the panel).

Getting results in native languages

To get function results or error messages in your native language, add the lang=language to request (e.g. lang=en). If you specify a non-existent language, a default language will be used (normally, it is English, en)

Output of function results

Output can be generated in XML, JSON and text format. If you wish to receive output results in a specific format, specify the out=format_name parameter.

The out parameter can have one of the following values:

  • xml - data structures in XML will be generated.
  • devel - similar to XML, but the document will contain data describing the user's interface.
  • text - data structures in the text format will be generated
  • json - data structures in JSON will be generated. More information can be found here.
  • JSONdata - similar to JSON. Only data are described
  • print - html for printing. Can be used only for data lists
  • xxxx - you can create a custom output format, if needed

If the out parameter is missing, such data are considered to be used by the browser and are converted into html.

Local calls to control panel

For local calls to the control panel you can use the internal utility mgrctl, which has a number of advantages

  • calls are sent directly to the control panel (they do not depend on the web-server)
  • there is no need to store a password, as authentication is always made with permissions of the user who run the script (if you need to perform operations as another user, use the su parameter described above).
  • has a built-in hints to all functions and their parameters relevant to your server
  

Format of requests and results

Requests are described as follows:

Function: a function name to be passed in the func parameter.

Parameters: a list of parameters and their brief description. If a function has no parameters, they are not specified. Parameters are passed in the format parameter=value.

Result: results may vary depending on the requested function:


List of elements (table)

The XML document will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<elem>element parameters on the list</elem>
	<elem>element parameters on the list</elem>
	...
	<elem>element parameters on the list</elem>
</doc>

Result: only the element parameters are described. They are one or several XML-nodes containing all possible attributes and values. For example:

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<elem>
		<name>foo.org</name>
		<admin>foo_admin</admin>
		<php/>
		<ssi/>
		<user used="1" limit="10"/>
		<disk used="0" limit="10"/>
		<traf used="3542" limit="8192"/>
	</elem>
	<elem>
		<name>example.com</name>
		<admin>example</admin>
		<cgi/>
		<php/>
		<ssi/>
		<frp/>
		<user used="5" limit="50"/>
		<disk used="39" limit="50"/>
		<traf used="1084" limit="4096"/>
	</elem>
</doc>

List of object parameters (form)

The XML document will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<elid>object id</elid>
	object parameters
</doc>

Result: the object parameters are only described. These are one or several XML nodes with all possible attributes and values that describe properties of that object. For example:

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<elid>example.com</elid>
	<name>example.com</name>
	<gid>1001</gid>
	<alias>www.example.com test.example.com</alias>
	<cgi/>
	<phptype>phpcgi</phptype>
	<ssi/>
	<frp/>
	<sslport>443</sslport>
	<alluser>50</alluser>
	<shelluser>5</shelluser>
	<domain>1</domain>
	<base>3</base>
	<traf>4096</traf>
	<disklimit>50</disklimit>
</doc>

Successful operation (action)

When creating, changing, removing, enabling or disabling an object, the XML document will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<ok/>
</doc>

If the web-server needs to be rebooted

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<ok>restart</ok>
</doc>

To reboot the web-server click the link below:

  http://IP-address/manager/billmgr?out=xml&func=restart

Error message

If an error occurred while processing your request, the XML document will look like this:

<?xml version="1.0" encoding="UTF-8"?>
<doc>
	<error>error message.</error>
</doc>

For more information, please refer to Error codes.

List of functions and parameters

Parameters and Function of every control panel are described in separate articles of our Documentation (the articles are generated automatically). They contains all of the functions and parameters, which, however, may be not available in your installation.

Use the mgrctl -i utility to get up-to-date information

To get a full list of BILLmanager functions, you may execute the command

/usr/local/mgr5/sbin/mgrctl -m billmgr -i 

To get data description (the lang parameter can be used to get information in a required language)

/usr/local/mgr5/sbin/mgrctl -m billmgr -i user lang=ru

How to generate an API request using the log file

The most convenient way to generate an API request is to perform a desired action in the panel interface and view the function and its parameters in the log file.

Complete the following steps:

1. Open the log file of the control panel with the tail command:

tail -f /usr/local/mgr5/var/XXXmgr.log | grep Request

where XXX is a short name of the control panel. For example: bill, isp, vm, dci

2. Execute a required action in the interface of the control panel. In the log file you will see the function being executed at that moment, and its parameters (it is shown in green color starting from INFO Request).