Editing packages through API

Hi there,

I am working on a Laravel application on which each user is assigned their own unique Hestia Package using the api.

I am stuck with a problem, I can’t find a method to update a package using the API. For example, I want to edit the bandwith of a package, the disk space etc…

I also wonder whether Hestia allows a single user to have multiple packages.

Thanks in advance!

I think we overwrite the existing packages via

exec(
		HESTIA_CMD . "v-add-user-package " . $tmpfile . " " . $v_package . " yes",
		$output,
		$return_var,
	);

I also wonder whether Hestia allows a single user to have multiple packages.

Why would you want it?

Personally I would set all users on unlimited disk / bandwidth and check once a day if they exceed the limits you set in your database… If not warn / suspend / invoice them accordingly

Hey, thanks for the quick reply.

So if I wanted to create / override a package through the API I would first need to make a request to create a temporary file, containing the params and then make a request to add the package?

Here is SDK: GitHub - ponasromas/HestiaCP-API: HestiaCP API SDK in PHP

Here is change user package function:

You can also link to the original command:

But it doesn’t create the user package that doesn’t;t exist …

I saw this method, but its not what I am looking for.

I am looking for an API endpoint that allows me to update the disk quota and bandwith, database limit etc.

Is there any endpoint that allows me to update the limits for a user or a package?

From what I saw in the code, the way packages are edited is by creating the package again to override the old data.

To create a package, i have to pass a temp file. But how would I create the temp file, with the params for the package? Using the API?

Yes that is the currently only method.

Could you give me some directions on how I would create the tmp file using the API?

That way I would atleast be able to override the package

v-make-tmp-file “content” filename
v-add-user-package “/tmp/$filename” packagename yes

Should work

But it would update every user that has this package assigned.

As told I would just use all users unlimited packages and pull it via the api daily… Unless you have enable file quotas then only update the disk usage .

Hey thanks for the reply

I found not find command v-make-tmp-file listed in https://github.com/hestiacp/hestiacp/tree/main/bin or is it only accessible via api.

Anyways, I was able to solve my issue.

The thing I worried about was that when a user already had a hestia account and a package, and purchased another package that it would override their previous package limits rather than increment them.

As I found out, multiple users can have the same email so now I am generating a random username for each order and keeping the email the same.

It is only accessible via api:

It creates a file in the /tmp/ folder

It is mainly used in the DNS cluster …