The add operation lets you add a site or a subdomain to an already existing subscription.

Request Packet Structure

A request XML packet adding a new subscription to Plesk database includes the add operation node:

<packet>
<site>
   <add>
   ...
   </add>
</site>
</packet>

The add node does not have a separate type, it is nested within the complex type (site.xsd). The add node has the following graphics representation:

image 66576

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.

  • gen_setup, required

    It is used to specify the general information about the site. Data type: complex. See the structure of this node in the Node add/gen_setup section.

  • hosting, optional

    It specifies hosting settings on a site. Data type: siteHostingAgentSet (site.xsd) . See the structure of this node in the Hosting section.

  • prefs, optional

    It specifies a collection of site preferences. Data type: domainPrefs (plesk_domain.xsd) . See the structure of this node in the Site Preferences section.

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 response packet is structured as follows:

image 66581

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.

  • result, required

    It wraps the result of the requested add operation. Data type: resultType (common.xsd).

  • status, required

    It returns the execution status of the add operation. Data type: string. Allowed values: ok | error.

  • errcode, optional

    Is used to return the error code when the add operation fails. Data type: unsignedInt.

  • errtext, optional

    Can be used to return an error message if the add operation fails. Data type: string.

  • id, optional

    It is required If the operation succeeds. Returns the unique identifier of a new site. Data type: integer.

  • guid, optional

    It is required if the operation succeeds. Returns the global unique identifier of a new site. Data type: string.

Samples

Creating a subdomain

The following request creates a subdomain named sub555.example.com for the domain example.com (id=1) belonging to the subscription with id 12 using the default values for the subdomain’s hosting settings:

<packet>
  <site>
   <add>
      <gen_setup>
        <name>sub555.example.com</name>
        <webspace-id>12</webspace-id>
        <parent-site-id>1</parent-site-id>
      </gen_setup>
    </add>
  </site>
</packet>

Response:

<packet version="1.6.3.0">
  <site>
    <add>
      <result>
        <status>ok</status>
        <id>19</id>
        <guid>54f7b3ae-f138-4b60-9a55-d897eec2a8e0</guid>
      </result>
    </add>
  </site>
</packet>

Creating a site

This is a sample request packet that creates a site named sample.tst belonging to the subscription with id 10.

<?xml version="1.0" encoding="UTF-8"?>
<packet>
  <site>
   <add>
      <gen_setup>
        <name>sample.tst</name>
        <webspace-id>10</webspace-id>
      </gen_setup>
      <hosting>
        <vrt_hst>
              <property>
                <name>fp</name>
                <value>false</value>
              </property>
              <property>
                <name>fp_ssl</name>
                <value>false</value>
              </property>
              <property>
                <name>fp_auth</name>
                <value>false</value>
              </property>
              <property>
                <name>fp_admin_login</name>
                <value/>
              </property>
              <property>
                <name>fp_admin_password</name>
                <value/>
              </property>
              <property>
                <name>ssl</name>
                <value>true</value>
              </property>
              <property>
                <name>php</name>
                <value>true</value>
              </property>
              <property>
                <name>php_handler_id</name>
                <value>fastcgi</value>
              </property>
              <property>
                <name>ssi</name>
                <value>false</value>
              </property>
              <property>
                <name>cgi</name>
                <value>true</value>
              </property>
              <property>
                <name>perl</name>
                <value>true</value>
              </property>
              <property>
                <name>python</name>
                <value>true</value>
              </property>
              <property>
                <name>asp</name>
                <value>false</value>
              </property>
              <property>
                <name>webstat</name>
                <value>awstats</value>
              </property>
              <property>
                <name>webstat_protected</name>
                <value>true</value>
              </property>
              <property>
                <name>errdocs</name>
                <value>true</value>
              </property>
              <property>
                <name>fastcgi</name>
                <value>true</value>
              </property>
              <property>
                <name>cgi_mode</name>
                <value>webspace</value>
              </property>
              <property>
                <name>www_root</name>
                <value>/sample</value>
              </property>
              <property>
                <name>safe_mode</name>
                <value>off</value>
              </property>
              <property>
                <name>open_basedir</name>
                <value>{WEBSPACEROOT}{/}{:}{TMP}{/}</value>
              </property>
            </vrt_hst>
      </hosting>
    </add>
  </site>
</packet>