• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Question Virtual Host Template Applied to REST API Domains?

jPG

New Pleskian
Hello,

I recently configured a virtual host template successfully applied to any new domain created manually in Plesk. When I use the Plesk REST API to create domains, the virtual host template is not applied. Is it possible to apply a virtual host template on API created domains?

Here's my current PHP API call function:

function createDomain($domain, $secretKey, $parentDomainGuid, $ownerClientGuid, $ipv4, $ipv6, $domainId){
$url = "https://" . $domain . ":8443/api/v2/domains";
$folder = $this->account->install_folder;
$request = array (
'name' => $folder . ' . ' . $domain,
'hosting_type' => 'virtual',
'hosting_settings' =>
array (
"www_root" => 'httpdocs/' . $folder,
'certificate_name'=> 'Lets Encrypt ' . $domain
),
'parent_domain' =>
array (
'id' => $domainId,
'name' => $domain,
'guid' => $parentDomainGuid,
),
'owner_client' =>
array (
'id' => 1,
'login' => 'admin',
'guid' => $ownerClientGuid,
'external_id' => '',
),
'ipv4' =>
array (
0 => $ipv4,
),
'ipv6' =>
array (
0 => $ipv6,
),
'plan' =>
array (
'name' => 'Unlimited',
),
);
}

Thanks in advance!
jPG
 
Also, could you explain your issue in more detail? What's different on your domain when you create it trough the REST API compared to when you manually create a domain?
 
Yeah, sorry. I am running Plesk Obsidian 18.0.42 and trying to add a vhost_nginx.conf file to the virtual template "conf" folder. It works like a charm for domains I create manually but not for the ones created by the API. Just wondering if I am missing something...
 
I would suggest contacting Plesk support and explaining your issue in detail to them so they can investigate the issue. Perhaps it's an undocumented limitation on the REST API or even a bug. If it's not, I am sure they can offer a possible solution.
 
Back
Top