Using v-generate-api-key in Example code

Hi All, a question on using v-generate-api-key as part of a php app (i.e. similar to )

I am using the following example however not seeing a result in $data. Am I missing something?
Thank you,


// Server credentials
$hst_hostname = '';
$hst_port = '2083';
$hst_returncode = 'no';
$hst_username = 'admin';
$hst_password = 'password!';
$hst_command = 'v-generate-api-key';

// Prepare POST query
$postvars = array(
  'returncode' => $hst_returncode,
  'cmd' => $hst_command

// Send POST query via cURL
$postdata = http_build_query($postvars);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://' . $hst_hostname . ':' . $hst_port . '/api/');
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);

// Parse JSON output
$data = json_decode($answer, true);

// Print result

Output of v-generate-api-key does not provide. any json output

echo $answer should work

Thanks @eris.

Unfortunately echo $answer; is null or “”.

My site is using SSL. (https://)

My site is on my HestiaCP server. (previously on Local)


Array ( [returncode] => no [cmd] => v-generate-api-key )

Tried returncode => yes with no change.

My user: admin or edwardc both are admins and use the new ACCESS KEY:SECRET KEY

Yes, v-generate-api-key works 100% ok from command line. (displays API KEY and Adds file in $HESTIA/data/keys/

Not sure what else I can provide to assist. Anything else I can provide? Try?
I really want to develop this WordPress Plugin to allow HestiaCP control. I believe it would be quite popular.

Thank you kindly,

First of all you should never use v-generate-api key it will be phased out soon as it provides the same security as admin / password.

If you want to “create” an api key make sure to create the new access key. With the correct settings. If needed you can add your own permissions sets in /usr/local/hestia/data/api/

What kind of access key did you create in case of the “*” where everything is allowed it only works on “admin” user not on “any” user with admin permissions

Check /var/log/hestia/auth.log for more details

Thanks for that. You made me stop and think about why I needed it - and as it’s being phased out.
I’ll stick with new Access Key. Thanks again @eris

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.