< All Topics

domain/editdnszone

Description

Edits or deletes an existing DNS zone record for an existing domain in a given SPanel user account.

Parameters

FieldTypeRequiredDescription
tokenstringYesAuthorizing API token – check API Basics for more information.
accountuserstringYesThe SPanel user account that is being managed or viewed.
actionstringYesThe category and function being executed.
domainstringYesThe domain for which the DNS zone is being edited.
recordarrayYesThe old DNS record. Every array key must be present in order to identify the record successfuly.
changesnull|arrayNoIf omitted (null) will delete the DNS record. Else, the changes parameter must contain an array with values to be changed using the same format as the record parameter.

Warning
Pay attention to the correct name and value formats – some DNS record types require dots at the end of the string.

Example

$endpointUrl = 'https://123.123.123.123/spanel/api.php';

$postData = [
  'token' => 'provided_auth_token',
  'accountuser' => 'spanelio',
  'action' => 'domain/editdnszone',
  'domain' => 'spanel.io',
  'record' => [ 'name' => 'spanel.io', 'ttl' => 86400, 'type' => 'NS', 'priority' => 0, 'value' => 'ns1.spanel.io' ],
  'changes' => ['value' => 'ns2.spanel.io']
];

$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $endpointUrl);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
$jsonOutput = curl_exec( $ch );

You can find more information about the Endpoint URL in our API Basics article.

In the example above, the only changed parameter is “value”. The API call will result in no changes for the existing DNS zone record except for the “value” parameter. It will be changed from “ns1.spanel.io” to “ns2.spanel.io”.

Output

{
    "result": "success",
    "data": {
        "msg": "The DNS entry \"spanel.io. 86400 IN NS ns2.spanel.io.\" was updated successfully"
    }
}

If the ‘changes’ parameter is omitted, the output is the following:

{
    "result": "success",
    "data": {
        "msg": "DNS entry \"spanel.io 86400 IN CNAME ns2.spanel.io.\" removed successfully"
    }
}
Previous domain/adddnsrecord
Table of Contents