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.
billing
mail-accounts
phpmyadmin-sso
purge-nginx-cache
sync-dns-cluster
update-dns-records
// 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' => 'test.com'
);
// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://127.0.0.1:8083/api/'); //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";
}
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
mail-accounts
phpmyadmin-sso
purge-nginx-cache
sync-dns-cluster
update-dns-records
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