Creating Subdomain
To create a subdomain, use the add operation and specify a parent website name, the subdomain name and subdomain properties.
Request Packet Structure
A request XML packet adding a new subdomain to Plesk, includes the add operation node:
<packet>
<subdomain>
<add>
...
</add>
</subdomain>
</packet>
The add node is presented by the SubdomainAddInputType
(subdomain.xsd
). Its graphical representation is as follows:
Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.
-
The parent node is required. It specifies a name of site/subdomain on which a subdomain is created. (Parent subdomain is supported in Plesk for Windows only.) Data type: string.
-
The name node is used and required on Windows only. It specifies a name of the subdomain. Data type: string. Use the asterisk (*) symbol to create a wildcard subdomain. Site visitors will be redirected to this subdomain regardless of the subdomain name they enter in a browser.
-
The home node is used on Plesk for Windows only. It specifies a path to the subdomain’s home directory relative to the parent site root directory. If the home node is left blank (
<home/>
), the root directory of the parent site is used. Data type: string.Another way to specify the subdomain’s home directory on Windows is the
www_root
property.Note: On Linux, you should use the
www_root
property (of theproperty
node) to specify the home directory for a website. -
The property node is required. It specifies a hosting setting of the created subdomain. To see the structure of this node, refer to the section Subdomain Properties. Data type: SubdomainPropertyType (
subdomain.xsd
).
Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.
Response Packet Structure
The add node of the output XML packet is structured as follows:
Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.
- The result node is required. It wraps the response retrieved
from the server. Data type: ResultType (
common.xsd
). - The status node is required. It specifies the execution status
of the add operation. Data type: result_status
(
common.xsd
). Allowed values:ok|error
. - The errcode node is required if the add operation fails. It returns the error code. Data type: unsignedInt.
- The errtext node is required if the add operation fails. It returns the error message. Data type: string.
- The id node is required if the add operation succeeds. It
returns the ID of a created subdomain. Data type: id_type
(
common.xsd
).
Possible Errors
- 1006 - Permission is denied.
- 1007 - Subdomain with such name already exists.
- 1015 - Parent site/subdomain is not found.
- 1019 - Invalid property name.
- 1023 - Operation failed.
- 1034 - Subdomains are not supported on sites without physical hosting.
Samples
This packet creates subdomain sample.example.com with the home directory /sample, sets FTP account credentials, sets the SSI support, and enables using SSI for *.htm and *.html files on the subdomain:
<packet>
<subdomain>
<add>
<parent>example.com</parent>
<name>sample</name>
<property>
<name>www_root</name>
<value>/sample</value>
</property>
<property>
<name>ssi</name>
<value>true</value>
</property>
<property>
<name>ssi_html</name>
<value>true</value>
</property>
</add>
</subdomain>
</packet>
For more properties examples, see Changing Subdomain Settings -> Request Samples.
Response:
<packet version="1.5.2.0">
<subdomain>
<add>
<result>
<status>ok</status>
<id>1</id>
</result>
</add>
</subdomain>
</packet>