How to create a domain with the specified template and plan using Remote API

Trying to setup Virtualmin hosting server with Paypal payment gateway, which supposedly should return the following parameters after successful payment by client: $domain_name, $configuration_template, $account_plan.

After this I’d like my server to automatically create a domain with returned parameters and in order to so going to use Virtualmin’s Remote Api, which gives the following example of php-script for ‘list-domains’ command:

<?php $result = shell_exec("wget -O - --quiet --http-user=root --http-passwd=pass --no-check-certificate 'https://localhost:10000/virtual-server/remote.cgi?program=list-domains'"); echo $result; ?>

Of course, I need to replace ‘list-domains’ with ‘create-domain’ command, but digging further I’ve found out this command has lot’s of such parameters as:

<?php virtualmin create-domain --domain --pass password-for-unix-user | --passfile password-file [--parent | --alias | --superdom] [--desc description-for-domain] [--email contact-email] [--user new-unix-user] [--group new-unix-group] [--unix] [--dir] [--dns] [--mail] [--web] [--webalizer] [--ssl] [--logrotate] [--mysql] [--ftp] [--spam] [--virus] [--webmin] [--virtualmin-awstats] [--virtualmin-dav] [--default-features] | [--features-from-plan] [--allocate-ip | --ip virtual.ip.address | --shared-ip existing.ip.address] [--ip-already] [--dns-ip address | --no-dns-ip] [--max-doms domains|*] [--max-aliasdoms domains] [--max-realdoms domains] [--max-mailboxes boxes] [--max-dbs databases] [--max-aliases aliases] [--quota quota-for-domain|UNLIMITED] [--uquota quota-for-unix-user|UNLIMITED] [--bandwidth bytes] [--template "name"] [--plan "name"] [--limits-from-plan] [--prefix username-prefix] [--db database-name] [--fwdto email-address] [--reseller name] [--mysql-pass password] [--skip-warnings] [--field-name value] ?>

Now, I really do not want to specify each parameter as it could mess with those I’ve already setup under Server Templates and Account Plans options via Virtualmin’s user interface. I hope there is simple way to feed the above-mentioned example script with just several parameters like $password, $domain_name, $configuration_template, $account_plan for all the detailed features to be picked up from already setup templates and plans.

What would be correct and simplified syntax for the create-domain command in my case? Would the following be sufficient or I really need to specify some other parameters:

<?php $password=substr(md5(rand().rand()), 0, 8); $result = shell_exec("wget -O - --quiet --http-user=root --http-passwd=passw --no-check-certificate '$domain_name&pass=$password&features-from-plan&limits-from-plan'"); echo $result; ?>

Unfortunately, I could not find how I can specify which template to use for the script.


You can do what you’re after using the --template “name” option to “create-domain”.

By passing in --template, you can specify which Server Template to use when creating the Virtual Server.


Thanks for prompt reply. So is it enough to pass just @template and @plan parameters in? No need to specify all other details?


If a parameter exists as part of the template or plan, as well as a separate “create-domain” option – passing that option into create-domain will override the template or plan.

So, if an option is set as you want in the template or plan, you don’t also need to pass it into create-domain.