Problems using the API

Hi all, I need to create through API of domains and databases and generate ssl however I can’t do it.
I used this PHP code:
I have a user account with administrator permissions and I used to authenticate both user and password and just hash as mentioned in your knowledge The response I get is always the same ie:

Query returned error code: <html>
<head><title>302 Found</title></head>
<center><h1>302 Found</h1></center>

To connect to the API I connect from the local server where the HestiaCP control panel is hosted so I have the permission, despite this I added the IP address as well in the permissions for the API.
Also in the CLI and API documentation I did not find how to set web template, backend template and document root customization.
Also there is an anomaly when I create the keys for the API from the hestiaCP panel, i.e. I only find these permissions how come? On the admin accounts. I don’t understand why only these are included.

What do you see if you visit:

This error:
Error: data received is null or invalid, check REST API | Hestia Control Panel

That is fine

Can you share the code that you have used for connection to ht api?

  // Prepare POST query
        $postvars = array(
            //'hash' => env('HESTIA_KEY_ID') . ':' . env('HESTIA_SECRET'),
            'user' => 'johndoe',
            'password' => 'password account johndoe',
            'returncode' => 'yes', //I also tried 'no' but nothing changes, still the same 302 message
            'cmd' => 'v-add-domain',
            'arg1' => 'johndoe', //this should be the domain name, I also tried other names and the account username
            'arg2' => ''

        // Send POST query via cURL
        $postdata = http_build_query($postvars);
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, ''); //I also tried using the server's IP address or hostname but it's still the same
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
        $answer = curl_exec($curl);

        if ($answer === 0) {
            return "Domain has been successfuly created\n";
        } else {
            return "Query returned error code: " . $answer . "\n";

Use https://

Perfect thanks friend, with https:// I can send api call, however I get this error:

Query returned error code: Error: Key (KEY ID) don’t have permission to run the command v-add-domain

If I go to the user settings from the Hestia panel to the user access keys page, I can only select these permissions, why?

Billing should have the permissions to run v-add-web-domain

If you need more permissions you can create a custom profile or create one via cli and use astrix * as permission

Perfect it works correctly now the domain is created. I have one last question: how do I always set “Web Template”, “Backend Template” from the API when creating the domain and customize the document root? I would like it to point to another domain and a specific folder

Webtemplate / Backend Template can be set with the package

For the costum docroot v-change-web-domain-docroot

The v-change-web-domain-docroot command doesn’t work I get the error with status 401.

Create a new api profile or use

v-add-access-key admin '*'

To get the correct permissions

I can’t execute the command I get these errors, I tried to log into the terminal with both an admin account and a user account.

/usr/local/hestia/func/ line 1575: /usr/local/hestia/conf/hestia.conf: Permission denied
grep: /usr/local/hestia/conf/hestia.conf: Permission denied
Error: user (USERACCOUNT) doesn't exist
/usr/local/hestia/func/ line 102: /usr/local/hestia/log/error.log: Permission denied

Run as root

Done already but I get these errors.

admin@manage:~$ sudo /usr/local/hestia/bin/v-add-access-key USERACCOUNT v-change-web-domain-docroot 
Error: API v-change-web-domain-docroot doesn't exist

I don’t want to activate all permissions for security reasons, but only specific permissions.

Should work …

It doesn’t work I always get the same error. How do I solve it?
Error: API v-change-web-domain-docroot doesn't exist

What api key profile do you use?

What do you mean by API profile? How do I create an API profile for an administrator account?

ls /usr/local/hestia/data/api/

Is a list of all command the specific profile can use or run you can create a new one if you want…

For billing it is


For example