Get Virtualizor

Lock VPS

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

NameMethodValueDescriptionRequired
actGETvsThe action specified to retrieve data after vps is lockedYes
vpsidGETIntThe ID of the vps which needs to be locked.Yes
actionGETtextThe value of the action should be "lock" for locking the VPSYes
reasonPOSTtextProvide 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"
}
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list