API
From VcPanel Enterprise : VPS Control Panel
vcPanel API is for the developers who need to integrate third party application with vcPanel and manage it remotely. You can operate your vcPanel control panel using API functions described below.
Api Error Codes
vcPanel have the following error codes implemented. This will help you to get the result from vcPanel.
200 - OK 101 - Node don't have license 102 - There is no default node configured 103 - No free ips 104 - Invalid plan 105 - Invalid OS template 106 - Invalid/Duplicate vps name 107 - Invalid Authentication 108 - Locked vps 109 - Unknown 110 - No default node 199 - License not found for node
You will always get the response code 200 , if your operations are correct.
Operations that can handle by current API
vcPanel API can handle the following current operations.
create - Create a vps suspend - Suspend a vps unsuspend - unsuspend a vps terminate - Terminate a vps
Please read some samples below,
Example 1 : Create A VPS
The following code is in php
<?php $posturl='http://YOURVCPANELSERVER:9966/'; $postfields['auth']=md5('thisisapikey'); // You need to get the API key from the vcPanel admin page. $postfields['vpsname']="test.yourdomain.com"; // This is your new vps name $postfields['vpsplan']="VPS1"; // This is your vps plan name. It must be same as plan name in vcPanel $postfields['clinetfname']="Tom"; // This is client name $postfields['clientlname']="Jan"; // This is client last name $postfields['clientemail']="tomjan@gmail.com"; // This is client email address and it is using as login ID for end user $postfields['clinetpass']=md5('mypass'); // This is your client password using for login into end user vcPanel $postfields['vpsos']="centos-5.4-i386-default"; // This vps template name. It must be same as in vcPanel admin panel $postfields['type']="openvz"; // This is type you can use openvz or xen . It is case sensitive $postfields['action']="create"; // This is the action you can use create / suspend /unsuspend/terminate . It is case sensitive $postfields['numip']="2"; // How many ips that you need to allocate for this new vps $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$posturl."vcpapi.php"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_TIMEOUT, 900); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); print_r($data); // This is the code return from the API ?>
