Add Recipes

Use the Add Recipes API to add a recipe to the Virtualizor panel. Recipes are predefined bash scripts that are created by admin for endusers. Only the 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 “1” if the recipe has been added successfully. Newly added recipes are active by default and are visible to the enduser.

HTTP Request

https://hostname:4085/index.php/act=addrecipe

Parameters

NameMethodValueDescriptionRequired
actGETaddrecipeThe action will return done as 1Yes
recipe_namePOSTtextName of the recipeYes
recipe_scriptPOSTtextRecipe script to be executedYes
descPOSTtextDescription given to the recipeNo
recipe_logoPOSTtextThe logo url for the recipeNo

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['recipe_name'] = 'test recipe';
    $post['recipe_logo'] = '';
    $post['recipe_script'] = 'echo "This is your test recipe" ';
    $post['desc'] = 'This is the description for test recipe';

    $output = $admin->add_recipes($post);

    print_r(json_encode($output));

?>

Output

{
    "title": "Add Recipe",
    "done": 1,
    "done_msg": "The Recipe has been added",
    "timenow": 1536152422,
    "time_taken": "0.219"
}
Was this helpful to you?