Use the Activate Recipe API to activate a recipe. Recipes are predefined bash scripts that are created by admin for endusers. Only activated recipes are visible to the enduser. These recipes can be executed on the VPS during their creation. Recipes can also be applied while the VPS is running, however you need to stop then start the VPS for the execution of the recipe to take place. The API response will contain "done" as the array of the IDs of the recipes that have been successfully activated.
HTTP Request
https://hostname:4085/index.php?act=recipes
Parameters
Name | Method | Value | Description | Required |
---|---|---|---|---|
act | GET | recipes | The action will return a list of recipes after the activating the specified recipe | Yes |
activate | POST | Int | The ID of the recipe that needs to be activated. For activating multiple recipes pass in the IDs as comma separated values | 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);
$post = array();
$post['activate'] = 7;
$post['activate'] = '7,8,9'; // for activating multiple recipes
$output = $admin->recipes($post);
print_r(json_encode($output));
?>
Output
{
"title": "Recipes",
"done": [
7,
8,
9
],
"recipe": {
"7": {
"rid": "7",
"name": "api recipe 2",
"code": "#!/bin/sh\n",
"desc": "",
"logo": "",
"status": "1"
},
"8": {
"rid": "8",
"name": "api recipe 3",
"code": "#!/bin/sh\n",
"desc": "",
"logo": "",
"status": "1"
},
"9": {
"rid": "9",
"name": "api recipe 4",
"code": "#!/bin/sh\n",
"desc": "",
"logo": "",
"status": "1"
}
},
"timenow": 1536162440,
"time_taken": "0.223"
}