Page tree
Skip to end of metadata
Go to start of metadata

Description

This function sets the primary domain hosted on a dedicated IP address for an account and all of its domains. The primary domain refers to the virtual host that the server returns when a visitor directly accesses the IP address.

For example, if both example1.com and example2.com are name-based virtual hosts on IP address 192.168.0.1, the primary virtual host appears when the visitor accesses the http://192.168.0.1/ location.

Examples 


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/set_primary_servername?api.version=1&servername=hostname.example.com&type=std
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/set_primary_servername?api.version=1&servername=hostname.example.com&type=std
 Command Line
whmapi1 set_primary_servername servername=hostname.example.com type=std


Notes:

  • Unless otherwise noted, you must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
    "metadata": {
        "version": 1,
        "reason": "OK",
        "result": 1,
        "command": "set_primary_servername"
    }
}
 Output (XML)
<result>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>set_primary_servername</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

   

Parameters

ParameterTypeDescriptionPossible valuesExample
servernamestring

Required

The ServerName value in Apache's VirtualHost section to set as primary for the IP address and port type.

Note:

You cannot select a hostname that exists on the server's main shared IP address, which you configure with the The IPv4 address (only one address) to use to set up shared IPv4 virtual hosts option in WHM's Basic WebHost Manager Setup interface (WHM >> Home >> Server Configuration << Basic WebHost Manager Setup).

A valid hostname.
hostname.example.com
typestring

The type of virtual host to set as primary.

This value defaults to std.

  • std — Port 80
  • ssl — Port 443
std

Returns

This function only returns metadata.