Get Virtualizor

Add User

Use the Add User API to add a user to the Virtualizor panel. Using this API you can create a normal user, cloud user and an admin user.

An admin user is a user with admin privileges, these privileges can be managed using the Administrator ACL module.

A cloud user can launch his own Virtual Private Server instances and manage new users as well. For a cloud user, you can adjust parameters like number of Virtual Private Servers that the user can create, amount of server resources that he can use and much more.

A normal user can only manage the VPS that has been assigned to it.

The API response will contain "done" as the user's ID on successful creation of the user.

HTTP Request

https://hostname:4085/index.php?act=adduser

Parameters

NameMethodValueDescriptionRequired
actGETadduserThe action specified to add the user,returns done as user ID in the result.Yes
adduserPOST1Set it to 1 to add the userYes
priorityPOSTIntThis specifies if the user is a user(0) or admin(1) or cloud (2)Yes
newpassPOSTtextThe password of the userYes
newemailPOSTtextThe email of the userYes
fnamePOSTtextThe first name of the userNo
lnamePOSTtextThe last name of the userNo
dnsplan_idPOSTIntThe dnsplan ID for the userNo
uplidPOSTIntThe user plan ID for the userNo
acl_idPOSTIntAccess Control ID for the userNo
num_vsPOSTIntThe maximum number of Virtual Private Servers this user can create. Zero (0) for unlimitedNo
num_usersPOSTIntThe maximum number of sub-users this user can create. Zero (0) for unlimitedNo
spacePOSTIntThe maximum disk space in GB that the user can use to create the vpsNo
ramPOSTIntThe maximum amount of ram in MB that the user can use to create the vpsNo
burstPOSTIntThe maximum amount of swap ram (For Other Kernels )or burst ram (For Open Vz) in MB that the user can use to create the vpsNo
bandwidthPOSTIntThe total bandwidth assigned to the userNo
cpuPOSTIntThe default cpu weight assigned to the user to create vpsNo
coresPOSTIntThe maximum number of cpu cores that the user can use to create the vpsNo
cpu_percentPOSTIntAll VPS created by the user would have this CPU %. This is per core base. E.g. If user creates VPS with 2 cores and percentage is 40 total 80% will be assigned.No
num_coresPOSTIntThe total number of cores allowed. Zero (0) means unlimited coresNo
num_ipv4POSTIntThe total number of ipv4 addresses that will be used for the vpsNo
num_ipv6_subnetPOSTIntThe total number of ipv6 subnet that will be used for the vpsNo
num_ipv6POSTIntThe total number of ipv6 addresses that will be used for the vpsNo
network_speedPOSTIntThe total network speed in KB/sNo
upload_speedPOSTIntThe total upload speed in KB/sNo
band_suspendPOST1/0If checked then all the cloud user's VPS(s) will be suspended if the specified bandwidth limit is exceededNo
service_periodPOSTIntThe billing cycle start date for bandwidth calculation (1-31)No
allowed_virtsPOSTarrayThe Virtualization type to allow this user (openvz,xen,xenhvm,kvm, xcp, xcphvm,lxc, proxo, proxk, proxl, vzk, vzo)No
sgsPOSTarrayThe array of servergroup that the user can useNo
mgsPOSTarrayThe array of media groups that the user can useNo
space_per_vmPOSTIntThe maximum space per vpsNo
total_iops_secPOSTIntThe total Iops per second (Only supported for kvm and proxk)
No
read_bytes_secPOSTIntThe read Iops per second (Only supported for kvm and proxk) No
write_bytes_secPOSTIntThe write Iops per second (Only supported for kvm and proxk)No

Sample Code

<?php
    require_once('/usr/local/virtualizor/sdk/admin.php');

    $key =  'your_api_key';
    $pass = 'your_api_pass';
    $ip = 'your_server_ip';

    $admin = new Virtualizor_Admin_API($ip, $key, $pass);

    $post = array();
    $post['adduser'] = 1;
    $post['priority'] = 0;
    $post['newemail'] = 'test@mail.com';
    $post['newpass'] = 'test';
    $post['dnsplan_id'] = 10;
    $post['uplid'] = 5;
    $post['acl_id'] = 0;
    $post['bandwidth'] = 0;
    $post['burst'] = 0;
    $post['cores'] = 0;
    $post['cpu'] = 0;
    $post['cpu_percent'] = 0;
    $post['network_speed'] = 0;
    $post['num_cores'] = 0;
    $post['num_ipv4'] = 0;
    $post['num_ipv6'] = 0;
    $post['num_ipv6_subnet'] = 0;
    $post['num_users'] = 0;
    $post['num_vs'] = 0;
    $post['ram'] = 0;
    $post['space'] = 0;
    $post['upload_speed'] = 0;

    $output = $admin->adduser($post);

    print_r(json_encode($output));

?>

Output

{
    "title": "Add User",
    "done": "60",
    "user_plans": [],
    "mgs": {
        "1": {
            "mgid": "1",
            "mg_name": "test",
            "mg_desc": "test_desc",
            "mg_type": "openvz"
        }
    },
    "servergroups": {
        "0": {
            "sgid": 0,
            "sg_name": "Default",
            "sg_reseller_name": "Default",
            "sg_desc": "Default Group",
            "sg_select": 0
        },
        "2": {
            "sgid": "2",
            "sg_name": "test_sg",
            "sg_reseller_name": "US",
            "sg_desc": "This is just test",
            "sg_select": "0"
        }
    },
    "timenow": 1535727645,
    "time_taken": "0.208"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list