Add User Plan

Use the Add User Plan API to create user plan on the Virtualizor panel. These plans help facilitate creation of user. Using this API you can create custom plans for Admin, Cloud and Normal user.

An admin user plan allows you to create user with admin privileges, these privileges can be managed using the Administrator ACL module.

A cloud user plan allows you create cloud user which can launch his own Virtual Private Server instances and manage new users as well. With cloud user plan 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. The API response will contain “done” as the ID of the created user plan on success.

HTTP Request

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

Parameters

NameMethodValueDescriptionRequired
actGETadduser_plansThe action specified to perform the operation and will return “done” as the user plan ID on successYes
plan_namePOSTtextThe unique name of the planYes
priorityPOSTIntThe type of user plan 0 for normal user, 1 admin user, 2 for cloudYes
dnsplan_idPOSTIntThe ID of the dns planNo
acl_idPOSTIntThe acl ID for admin userNo
num_vsPOSTIntThe maximum number of Virtual Private Servers this user can create. Zero (0) for unlimitedNo
inhouse_billingPOST1/0If enabled, Virtualizor will calculate resource usage and create invoices for the VPSesNo
num_usersPOSTIntThe maximum number of sub-users this user can create. Zero (0) for unlimited.No
spacePOSTIntMax Disk Space in GBNo
ramPOSTIntThe Maximum amount ram in MBNo
burstPOSTIntThe Maximum amount burst in MBNo
bandwidthPOSTIntZero (0) means unlimited bandwidthNo
cpuPOSTIntDefault CPU weightNo
coresPOSTIntMax Cores per VPS. The user cannot create a VPS above this limitNo
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 max number of ipv4 ips that the user can createNo
num_ipv6_subnetPOSTIntThe max number of ipv6 subnet that the user can createNo
num_ipv6POSTIntThe max number of ipv6 ips that the user can createNo
network_speedPOSTIntThe network speed in KB/s. Pass 0 or leave empty for no restriction.No
upload_speedPOSTIntThe upload speed in KB/s. Pass 0 or leave empty for no restriction.No
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, valid values (0-31)No
allowed_virtsPOSTarrayThe Virtualization type to allow this user refer below table for valid valuesNo
sgsPOSTarrayThe array of server group IDsNo
mgsPOSTarrayThe array of media group valuesNo

Allowed Virtualization

( openvz | xen | xenhvm | kvm | xcp | xcphvm | lxc | proxo | proxk | proxl | vzk | vzo )

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['plan_name'] = 'api_plan';
    $post['priority'] = 0;

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

    print_r(json_encode($output));
?>

Output

{
    "title": "Add User Plan",
    "done": "5",
    "mgs": {
        "3": {
            "mgid": "3",
            "mg_name": "testing for apia",
            "mg_desc": "Testing for the api",
            "mg_type": "kvm"
        }
    },
    "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": 1537471672,
    "time_taken": "0.131"
}
Was this helpful to you?