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=createtemplate
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | createtemplate | The action specified to perform operation and return done as 1 after the template has been created successfully | Yes |
vpsid | Post | Int | VPS ID whose template needs to be created | Yes |
tmpname | POST | text | Name to be given to the template | Yes |
extra | POST | text | Extra things to specified before creating a template | No |
fstype | POST | 1/0 | File system type of the template (only for xen vps) | No |
perf_ops | POST | 1/0 | Extra operation that need to be performed while creating a template | No |
noresizefs | POST | 1/0 | If set, the filesystem of the template would be resized | No |
pygrub | POST | 1/0 | If 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"
}