Use the Lock VPS API to lock VPS present on your server by passing the VPS ID to the API. The API response contains "done" as "true" on successful locking of the VPS (Since 3.0.8+).
HTTP Request
https://hostname:4085/index.php?act=vs&action=lock&vpsid=VPSID
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | vs | The action specified to retrieve data after vps is locked | Yes |
vpsid | GET | Int | The ID of the vps which needs to be locked. | Yes |
action | GET | text | The value of the action should be "lock" for locking the VPS | Yes |
reason | POST | text | Provide reason for locking the VM(s). If not provided by default it will be "Locked by admin" | 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);
$vid = 3582;
$reason = 'Locked for a reason';
$output = $admin->lock($vid, $reason);
print_r(json_encode($output));
?>
Output
{
"title": "Virtual Servers",
"done": true,
"done_msg": "VPS Locked",
"vsop": {
"action": "lock",
"id": 3582,
"serid": "0",
"status": {
"3582": 1
}
},
"timenow": 1535125750,
"time_taken": "4.432"
}