This can be done using the API1 call Mysql::adddb
when authenticated as root or a reseller that owns this account, you can call this via the cpanel xml-api api1/api2 wrapper, like thus:
Code:
/xml-api/cpanel?cpanel_xmlapi_module=Mysql&cpanel_xmlapi_func=adddb&cpanel_xmlapi_apiversion=1&arg-0=__DATABASE_NAME_GOES_HERE__&cpanel_xmlapi_user=__USERNAME_GOES_HERE__
Now, we do provide an xml-api php client that allows you to work with this in a much simpler manner:
PHP Code:
include("xmlapi.php");
$ip = "127.0.0.1";
$root_pass = "testing";
$account = "cptest";
$database = "dbname";
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root",$root_pass);
$xmlapi->set_debug(1);
print $xmlapi->api1_query($account, "Mysql", "adddb", array($database) );
Now, with this setup, you'll have to pull your $root_pass from REMOTE_PASS in the CGI environment and change the user querying the xml-api, but this will work.
Another alternative is to use the first example I showed you via javascript.