Edit Recipe

Use the Edit Recipe API to update a recipe present on 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 successfully updated.

HTTP Request

https://hostname:4085/index.php?act=editrecipe&rid=RID

Parameters

NameMethodValueDescriptionRequired
actGETeditrecipeThe action will return done as 1 after the recipes has been editedYes
ridGETIntThe recipe IDYes
namePOSTtextThe name of the recipeYes
codePOSTtextThe code that will be executed by the recipe at the time of callYes
descPOSTtextThe description for the recipeNo
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['rid'] = 23;
    $post['name'] = 'test_recipe1';
    $post['code'] = 'This is your test recipe';
    $post['desc'] = 'This is the description for test recipe';

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

    print_r(json_encode($output));
?>

Output

{
    "title": "Edit Recipe",
    "done": 1,
    "done_msg": "Recipe has been updated",
    "timenow": 1536159013,
    "time_taken": "0.204"
}
Was this helpful to you?