Use the Restart VPS API to restart the VPS present on your server by passing the VPS ID to API. The API response returns "done" as "true" when a restart signal is sent to the VPS.
HTTP Request
https://hostname:4085/index.php?action=vs&action=restart&vpsid=VPSID
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | vs | The action specified to retrieve data after vps is restarted | Yes |
vpsid | GET | Int | The ID of the vps which needs to be restarted | Yes |
action | GET | text | The value of the action should be "restart" for restarting the VPS | Yes |
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);
$vid = 51;
$output = $admin->restart($vid);
print_r(json_encode($output));
?>
Output
{
"title": "Virtual Servers",
"done": true,
"done_msg": "Restart signal has been sent to the VPS",
"vsop": {
"action": "restart",
"id": 51,
"serid": "0",
"output": "Domain v1009 created from /etc/libvirt/qemu/v1009.xml\n",
"status": {
"51": 1
}
},
"timenow": 1535126160,
"time_taken": "4.123"
}