Create Template

Use the Create Template API to create a custom template for the Virtual Private Server, using an existing Virtual Private Servers OS. This features allows you to easily make multiple identical VPSes. The API response will contain “done” as “1” on successful creation of the template.

For more information, you can refer this Create OS template guide.

HTTP Request

https://hostname:4085/index.php?act=edittemplate&osid=OSID

Parameters

NameMethodValueDescriptionRequired
actGETcreatetemplateThe action specified to perform operation and return done as 1 after the template has been created successfullyYes
vpsidPostIntVPS ID whose template needs to be createdYes
tmpnamePOSTtextName to be given to the templateYes
extraPOSTtextExtra things to specified before creating a templateNo
fstypePOST1/0File system type of the template (only for xen vps)No
perf_opsPOST1/0Extra operation that need to be performed while creating a templateNo
noresizefsPOST1/0If set, the filesystem of the template would be resizedNo
pygrubPOST1/0If set the pygrub will be enabled (only for xen vps)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['vpsid'] = 3394;
    $post['tmpname'] = 'test_template';
    $post['extra'] = '';
    $post['fstype'] = '';
    $post['perf_ops'] = 0;
    $post['noresizefs'] = 0;

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

    print_r(json_encode($output));

?>

Output

{
    "title": "Create Template",
    "actid": "448",
    "done": 1,
    "timenow": 1536061290,
    "time_taken": "0.262"
}
Was this helpful to you?