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
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | adduser | The action specified to add the user,returns done as user ID in the result. | Yes |
adduser | POST | 1 | Set it to 1 to add the user | Yes |
priority | POST | Int | This specifies if the user is a user(0) or admin(1) or cloud (2) | Yes |
newpass | POST | text | The password of the user | Yes |
newemail | POST | text | The email of the user | Yes |
fname | POST | text | The first name of the user | No |
lname | POST | text | The last name of the user | No |
dnsplan_id | POST | Int | The dnsplan ID for the user | No |
uplid | POST | Int | The user plan ID for the user | No |
acl_id | POST | Int | Access Control ID for the user | No |
num_vs | POST | Int | The maximum number of Virtual Private Servers this user can create. Zero (0) for unlimited | No |
num_users | POST | Int | The maximum number of sub-users this user can create. Zero (0) for unlimited | No |
space | POST | Int | The maximum disk space in GB that the user can use to create the vps | No |
ram | POST | Int | The maximum amount of ram in MB that the user can use to create the vps | No |
burst | POST | Int | The maximum amount of swap ram (For Other Kernels )or burst ram (For Open Vz) in MB that the user can use to create the vps | No |
bandwidth | POST | Int | The total bandwidth assigned to the user | No |
cpu | POST | Int | The default cpu weight assigned to the user to create vps | No |
cores | POST | Int | The maximum number of cpu cores that the user can use to create the vps | No |
cpu_percent | POST | Int | All 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_cores | POST | Int | The total number of cores allowed. Zero (0) means unlimited cores | No |
num_ipv4 | POST | Int | The total number of ipv4 addresses that will be used for the vps | No |
num_ipv6_subnet | POST | Int | The total number of ipv6 subnet that will be used for the vps | No |
num_ipv6 | POST | Int | The total number of ipv6 addresses that will be used for the vps | No |
network_speed | POST | Int | The total network speed in KB/s | No |
upload_speed | POST | Int | The total upload speed in KB/s | No |
band_suspend | POST | 1/0 | If checked then all the cloud user's VPS(s) will be suspended if the specified bandwidth limit is exceeded | No |
service_period | POST | Int | The billing cycle start date for bandwidth calculation (1-31) | No |
allowed_virts | POST | array | The Virtualization type to allow this user (openvz,xen,xenhvm,kvm, xcp, xcphvm,lxc, proxo, proxk, proxl, vzk, vzo) | No |
sgs | POST | array | The array of servergroup that the user can use | No |
mgs | POST | array | The array of media groups that the user can use | No |
space_per_vm | POST | Int | The maximum space per vps | No |
total_iops_sec | POST | Int | The total Iops per second (Only supported for kvm and proxk) | No |
read_bytes_sec | POST | Int | The read Iops per second (Only supported for kvm and proxk) | No |
write_bytes_sec | POST | Int | The 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"
}