Description

This function deletes a subdomain.

Examples


https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=username&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=SubDomain&cpanel_jsonapi_func=delsubdomain&domain=subdomain.example.com

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Remove a subdomain.
$delsubdomain = $cpanel->api2(
    'SubDomain', 'delsubdomain', 
        array(
        'domain' => 'subdomain.example.com'
    )
);

 

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Remove a subdomain.
my $delsubdomain = $cpliveapi->api2(
    'SubDomain', 'delsubdomain',
	{
        'domain' => 'subdomain.example.com'
    } 

);

 

cpapi2 --user=username SubDomain delsubdomain domain=subdomain.example.com

{ 
   "cpanelresult":{  
      "apiversion":2,
      "func":"delsubdomain",
      "data":[  
         {  
            "reason":"Bind reloading on example using rndc zone: [example.tld] The subdomain "subdomain.example.com" has been removed.",
            "result":1
         }
      ],
      "event":{  
         "result":1
      },
      "module":"SubDomain"
   }
}

Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The name of the subdomain to delete.

A valid domain name.

 

subdomain.example.com

To delete the subdomain of an addon domain, separate the subdomain with an underscore (_) instead of a dot (.). For example, use the following format:

subdomain_addondomain.tld

Returns

ReturnTypeDescriptionPossible valuesExample
reasonstring

A success or failure message.

A string that describes the success or error.

Bind reloading on example using rndc zone: [example.tld] The subdomain "subdomain.example.com" has been removed.
resultBoolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1