Create VM


This article provides a guide for a VPS Reseller user to create VM via API.

Use Create VM API to create new VPS on your server.

This function is for cloud user.

HTTP Request

https://vm1.apivps.com:4083/index.php?act=create

Parameters

Parameters Type Value Description
act GET create The action will create VPS instance for a particular user.
virt POST virt The virtualization to be specified relevant to which the VPS will be created.
sgid POST Int The server group where the VPS will created and assigned.
rootpass POST rootpass The root password that will be set for the VPS..
hostname POST hostname Hostname for the VPS will be set.
space POST Int This will set the disk space for the VPS. Also it will assign the disk space comparing with the space the individual user has declared.
ram POST Int This will set the RAM for the VPS. Also it will assign the RAM comparing with the RAM the individual user has declared.
swapram POST Int This will use the disk space to create swap.
bandwidth POST Int This will assign the bandwidth to the VPS and will also check available bandwidth that is assigned to the user.
uid POST Int The user id under whom the VPS will be created.
cores POST Int Number of CPU cores that will be used by the VPS. Assigned at the time of creation.
ips POST Int Number of ipv4 addresses that will be assigned to the VPS.
ips_int POST Int Number of internal IP addresses that will be assigned to the VPS.
ipv6 POST Int Number of IPv6 addresses that will be assigned to the VPS.
ipv6_subnet POST Int Number of IPv6 subnet that will be assigned to the VPS.
vnc POST 1/0 If set then VNC will be set for the VPS.
vncpass POST vncpass VNC password will be set automatically.
iso POST iso Create VPS using iso present on the server.
boot POST boot Sets the boot order in the VPS.
band_suspend POST 1/0 If set then VPS will be suspended if the bandwidth limit is exceeded.
osreinstall_limit POST Int This sets the value for limit for OS reinstallation.
osid POST Int This will assign the osid to the VPS for installing OS template.
mg POST mg IF this is set then the OS template belonging to the media group will be displayed.
nic POST string Provide Virtual Network Interface Type.
ssh_options POST Int Provide one of these ssh_options: add_ssh_keys, generate_keys, use_ssh_keys, we have provided detailed information about these options below.
sshkey POST Int Provide public SSH key.
private_key POST Int Provide private key (compulsory if generate_keys is passed in ssh_options).
existing_key POST array Provide an array of public key (compulsory if use_ssh_keys is passed in ssh_options).
bios POST String Provide bios seabios/uefi (Default is seabios) will be applied only while booting with iso.(KVM ONLY).
addvs POST 1 If set then the VPS will be created.

SSH Options

There are three types of ssh_options which are described below:

  1. add_ssh_keys: Pass your own public SSH key in post to add that SSH key in your VPS.
  2. generate_keys: If you want to create new pair of keys then you will first need to generate using the following link: https://radwebhosting.com/client_area/knowledgebase/348/Add-SSH-Key.html Once you have made the pair you will need to pass it to the ADDVS calls using following variables : $post[sshkey'] = 'PUBLIC_KEY'; $post['private_key '] = 'PRIVATE_KEY';
  3. use_ssh_keys :If you want to use existing key then first you will need to get list of sshkey using the following link: https://radwebhosting.com/client_area/knowledgebase/349/List-SSH-Keys.html Once you have made the pair you will need to pass it to the ADDVS calls using following variables: $post[existing_key'][] = 'PUBLIC_KEY 1'; $post['existing_key '][] = 'PUBLIC_KEY 2';

Sample Code

PHP

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

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

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

    $post = array();
    $post['virt'] = 'kvm';
    $post['sgid'] = 12;
    $post['rootpass'] ='Test123!!';   
    $post['hostname'] = 'testcloud' ;
    $post['space'] = 20 ;
    $post['ram'] = 1024;
    $post['swapram'] = 1024;
    $post['bandwidth'] = 1000;
    $post['uid'] = 372;
    $post['cores'] = 2;
    $post['ips'] = 1;
    $post['vnc'] = 1;
    $post['vncpass'] = 'testvnc';
    $post['band_suspend'] = 1;
    $post['osreinstall_limit'] = 0;
    $post['osid'] = 955;
    $post['addvs'] = 1;

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

    print_r(json_encode($output));
?>

Curl

curl -k -X POST -d "addvs=1&virt=kvm&sgid=12&rootpass=Test123!!&hostname=testcloud&space=20&ram=1024&swap=1024&bandwidth=1000&uid=372&cpu=256&cores=8&ips=1&vnc=1&vncpass=testvnc&osid=955" -L "https://vm1.apivps.com:4083/index.php?act=create&api=json&apikey=your_api_key&apipass=your_api_pass"

Output

{
    "uid": "372",
    "act": "create",
    "timezone": 1,
    "timenow": "June 6, 2023,  2:09 am",
    "vpsid": "9999",
    "username": "test@test.com",
    "user_type": "2",
    "preferences": {
        "fname": "test",
        "lname": "test",
        "theme": "default",
        "language": "english",
        "timezone": 1
    },
    "url": "index.php?",
    "rdns": {
        "pdnsid": "12"
    },
    "pdns": {
        "pdnsid": "12"
    },
    "support_link": "http://radwebhosting.com",
    "disable_login_logo": 1,
    "title": "Launch Instance",
    "resources": {
        "num_vs": 99999,
        "num_users": 15,
        "space": 20,
        "ram": 1024,
        "burst": 1024,
        "bandwidth": 1000,
        "num_ipv4": 5,
        "num_ipv6_subnet": 1,
        "num_ipv6": "1",
        "cores": "8",
        "num_cores": "9996",
        "network_speed": "128000",
        "upload_speed": "128000",
        "allowed_virts": {
            "kvm": "kvm"
        },
        "cloud_allow_virtio": 1
    },
    "usage": {
        "num_cores": "4"
    },
    "users": {
        "372": {
            "uid": "372",
            "email": "test@test.com"
        }
    },
    "ostemplates": {
        "955": {
            "osid": "955",
            "type": "kvm",
            "name": "centos-7.8-x86_64",
            "filename": "centos-7.8-x86_64.img",
            "size": "1560281088",
            "pygrub": "0",
            "drive": "",
            "hvm": "0",
            "perf_ops": "1",
            "active": "1",
            "url": "http://files.virtualizor.com/ostemplates.php?osid=955",
            "distro": "centos",
            "Nvirt": "kvm"
        },
        "943": {
            "osid": "943",
            "type": "kvm",
            "name": "centos-8.2-x86_64",
            "filename": "centos-8.2-x86_64.img",
            "size": "2000683008",
            "pygrub": "0",
            "drive": "",
            "hvm": "0",
            "perf_ops": "1",
            "active": "1",
            "url": "http://files.virtualizor.com/ostemplates.php?osid=943",
            "distro": "centos",
            "Nvirt": "kvm",
            "mg": [16]
        },
        "878": {
            "osid": "878",
            "type": "kvm",
            "name": "debian-10-x86_64",
            "filename": "debian-10-x86_64.img",
            "size": "2738880512",
            "pygrub": "0",
            "drive": "",
            "hvm": "0",
            "perf_ops": "1",
            "active": "1",
            "url": "http://files.virtualizor.com/ostemplates.php?osid=878",
            "distro": "debian",
            "Nvirt": "kvm"
        },
        "979": {
            "osid": "979",
            "type": "kvm",
            "name": "debian-11-x86_64",
            "filename": "debian-11-x86_64.img",
            "size": "2202009600",
            "pygrub": "0",
            "drive": "",
            "hvm": "0",
            "perf_ops": "1",
            "active": "1",
            "url": "http://files.virtualizor.com/ostemplates.php?osid=979",
            "distro": "debian",
            "Nvirt": "kvm"
        },
        "812": {
            "osid": "812",
            "type": "kvm",
            "name": "ubuntu-18.04-x86_64",
            "filename": "ubuntu-18.04-x86_64.img",
            "size": "1732247552",
            "pygrub": "0",
            "drive": "",
            "hvm": "0",
            "perf_ops": "1",
            "active": "1",
            "url": "http://files.virtualizor.com/ostemplates.php?osid=812",
            "distro": "ubuntu",
            "Nvirt": "kvm"
        },
    },
    "isos": {
        "	debian-9.4.0-amd64-netinst.iso": {
            "iso": "debian-9.4.0-amd64-netinst.iso",
            "mg": [17],
            "name": "debian-9.4.0-amd64-netinst.iso",
            "filename": "debian-9.4.0-amd64-netinst.iso",
            "size": 305135616,
            "distro": "debian"
        },
        "Windows_2022_SERVER_EVAL_x64.iso": {
            "iso": "Windows_2022_SERVER_EVAL_x64.iso",
            "mg": "",
            "name": "Windows_2022_SERVER_EVAL_x64.iso",
            "filename": "Windows_2022_SERVER_EVAL_x64.iso",
            "size": 5043650560,
            "distro": "windows"
        },
    },
    "servergroups": [{
        "sgid": 0,
        "sg_name": "test",
        "sg_reseller_name": "USA",
        "sg_desc": "This is just desc",
        "sg_select": 0,
        "virts": {
            "kvm": "kvm"
        }
    }],
    "done": {
        "done": "9999",
        "msg": "The Virtual Server has been created",
        "goto": "act=listvs"
    },
    "done_msg": "The Virtual Server has been created",
    "newvs": {
        "type": "kvm",
        "sgid": 12,
        "rootpass": "test123",
        "hostname": "testcloud",
        "space": 20,
        "ram": 1024,
        "burst": 0,
        "swapram": 1024,
        "bandwidth": 1000,
        "uid": 372,
        "cores": 8,
        "num_ipv4": 5,
        "num_ipv6": 1,
        "num_ipv6_subnet": 1,
        "vnc": 1,
        "vncpass": "vncpass",
        "shadow": 0,
        "iso": "",
        "boot": "cda",
        "band_suspend": 1,
        "tuntap": 0,
        "osreinstall_limit": 0,
        "mg": "",
        "osid": 955,
        "virtio": 1,
        "node_select": 1,
        "server_group": 8,
        "num_ips": 5,
        "num_ips6": 1,
        "num_ips6_subnet": 1,
        "addvps": 1,
        "vpsid": "9999",
        "ips": ["10.10.100.6"],
        "ips6": [],
        "ipv6_subnet": []
    },
    "res_limit": {
        "num_vs": "100000",
        "num_users": "15",
        "space": "50",
        "ram": "2048",
        "bandwidth": "1000000",
        "num_ipv4": "50",
        "num_ipv6_subnet": "15",
        "num_ipv6": "15",
        "num_cores": "10000",
        "cores": "8"
    },
    "virts": {
        "kvm": "kvm",
    },
    "virt_lang": {
        "kvm": "KVM",
    },
    "time_taken": "3.119"
}

Conclusion

You now know how to create VM as a VPS Reseller.

  • vps api, api
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Add SSH Key

This article provides a guide for a VPS Reseller user to add SSH key via API. Use Add SSH key...

Cloud Resources

This article provides a guide for a VPS Reseller user to get cloud resources available to the...

Delete VM

This article provides a guide for a VPS Reseller user to delete VM via API. Use Delete VM API to...

Add ISO

This article provides a guide for a VPS Reseller user to add a new ISO to a VPS via API. Use Add...

List SSH Keys

This article provides a guide for a VPS Reseller user to list SSH keys via API. Use List SSH...