Child pages
  • WHM API 1 Functions - set_primary_servername
Skip to end of metadata
Go to start of metadata

 

Description

This function sets the primary domain on an IP address and port for an account's sites. 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:

  • 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. 
  • We introduced this functionality in cPanel & WHM version 11.52.0.8.

 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.

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.