Child pages
  • cPanel API 2 Functions - ZoneEdit::edit_zone_record

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt

This function edits a zone record.

Include Page
LIB:_cPanelAPI2NoEquivalent
LIB:_cPanelAPI2NoEquivalent

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@12665
MultiExcerptNameAPIDisabledDNSRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples 


Panel
bgColor#FFFFFF
borderStylenone


Expand
titleWHM API (JSON)


Code Block
languagetext
https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=edit_zone_record&Line=5&domain=example.com&name=sub&type=A&txtdata=v=blahblahblah&cname=example.com&address=10.10.10.10&ttl=14400&class=IN

Include Page
LIB:_CallFromWHMAPILink
LIB:_CallFromWHMAPILink


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Edit a type "A" zone record on "example.com"
$edit_zone_record = $cpanel->api2(
    'ZoneEdit', 'edit_zone_record',
 array(
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'sub',
        'type' => 'A',
        'address' => '10.10.10.10',
        'ttl' => '14400',
        'class' => 'IN',
    ) 
);

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Edit a type "CNAME" zone record on "example.com"
$edit_zone_record = $cpanel->api2(
    'ZoneEdit', 'edit_zone_record',
 array(
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'sub',
        'type' => 'CNAME',
        'cname' => 'example.com',
        'ttl' => '14400',
        'class' => 'IN',
     ) 
);

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Edit a type "TXT" Zone Record on "example.com"
$edit_zone_record = $cpanel->api2(
    'ZoneEdit', 'edit_zone_record',
 array(
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'sub',
        'type' => 'TXT',
        'txtdata' => 'v=blahblahblah',
        'ttl' => '14400',
        'class' => 'IN',
     ) 
);

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Edit a type "AAAA" Zone Record on "example.com"
$edit_zone_record = $cpanel->api2(
    'ZoneEdit', 'edit_zone_record',
 array(
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'genesis',
        'type' => 'AAAA',
        'address' => 'abac:abab:acab:abac:abab:acab:abac:ab11',
        'ttl' => '14400',
        'class' => 'IN',
     ) 
);

$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Edit a type "SRV" Zone Record on "example.com"
$edit_zone_record = $cpanel->api2(
    'ZoneEdit', 'edit_zone_record',
 array(
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'autocorrect',
        'type' => 'SRV',
        'txtdata' => 'v=blahblahblah',
        'ttl' => '14400',
        'class' => 'IN',
     ) 
);
 
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Edit a type "CAA" Zone Record on "example.com"
$edit_zone_record = $cpanel->api2(
    'ZoneEdit', 'edit_zone_record',
 array(
        'domain' => 'example.com',
        'name'   => 'autocorrect',
        'type'   => 'CAA',
        'flag'   => '0',
		'tag'    => 'issue',
		'value'  => 'totallyrealca.tld',
        'ttl'    => '14400',
        'class'  => 'IN',
     ) 
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Edit a type "A" Zone Record on "example.com"
my $edit_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'sub',
        'type' => 'A',
        'address' => '10.10.10.10',
        'ttl' => '14400',
        'class' => 'IN',
   }
);

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Edit a type "CNAME Zone Record on "example.com"
my $add_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'sub',
        'type' => 'CNAME',
        'cname' => 'example.com',
        'ttl' => '14400',
        'class' => 'IN',
   }
);

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Edit a type "TXT" Zone Record on "example.com"
my $edit_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'sub',
        'type' => 'TXT',
        'txtdata' => 'v=blahblahblah',
        'ttl' => '14400',
        'class' => 'IN',
   }
);

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Edit a type "AAAA" Zone Record on "example.com"
my $add_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'genesis',
        'type' => 'CNAME',
        'address' => 'abac:abab:acab:abac:abab:acab:abac:ab11',
        'ttl' => '14400',
        'class' => 'IN',
   }
);

my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Edit a type "TXT" Zone Record on "example.com"
my $edit_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'Line' => '5',
        'domain' => 'example.com',
        'name' => 'autocorrect',
        'type' => 'SRV',
        'txtdata' => 'v=blahblahblah',
        'ttl' => '14400',
        'class' => 'IN',
   }
);
 
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Edit a type "CAA" Zone Record on "example.com"
my $edit_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'domain'  => 'example.com',
        'name'    => 'autocorrect',
        'type'    => 'CAA',
        'flag'    => '0',
		'tag'     => 'issue'
		'value'   => 'totallyrealca.tld'
        'ttl'     => '14400',
        'class'   => 'IN',
   }
);
 
# Edit a type "MX" Zone Record on "example.com"
my $edit_zone_record = $cpliveapi->api2(
    'ZoneEdit', 'edit_zone_record',
   { 
        'domain'      => 'example.com',
        'name'        => 'autocorrect',
        'type'    	  => 'MX',
        'exchange'    => '0',
		'preference'  => '10',
        'ttl'         => '14400',
        'class'       => 'IN',
   }
);

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink


Expand
titlecPanel Tag System (deprecated)

Include Page
LIB:_cPanelAPI2cPanelTagsWarning
LIB:_cPanelAPI2cPanelTagsWarning


Expand
titleCommand Line


Code Block
languagebash
cpapi2 --user=username ZoneEdit edit_zone_record Line=5 domain=example.com name=sub type=A txtdata=v%3Dblahblahblah cname=example.com address=10.10.10.10 ttl=14400 class=IN

Include Page
LIB:_cPanelAPI2CLINote
LIB:_cPanelAPI2CLINote


Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{
  "cpanelresult": {
    "apiversion": 2,
    "func": "edit_zone_record",
    "data": [
      {
        "result": {
          "newserial": 2014101603,
          "statusmsg": "Bind reloading on hostname using rndc zone: [example.com]\n",
          "status": 1
        }
      }
    ],
    "event": {
      "result": 1
    },
    "module": "ZoneEdit"
  }
}


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote


Parameters

ParametersTypeDescriptionPossible valuesExample
lineinteger

Required

The line in the zone file to edit.

A positive integer.5
domainstring

Required

The record's domain.

A valid domain name.example.com
namestring

Required

The record's name, which maps to the subdomain.

A valid string.sub
typestring

Required

The record type.

  • A
  • AAAA
  • CAA
  • CNAME
  • MX

    Note
    titleNote:

    This function can only edit AAAA, MX, and SRV records if the cPanel account's hosting provider enables the following settings in WHM's Feature Manager interface (WHM >> Home >> Packages >> Feature Manager):

    • Ability to Change MX
    • Zone Editor (AAAA, CAA, SRV, TXT)


  • SRV
  • TXT
A
txtdatastring

The record's text data.

Note
titleNote:
This parameter is required if you use TXT as the type parameter's value.


A valid string.v=blahblahblah
targetstring

The service's target host.

Note
titleNotes:
  • This parameter is required if you use SRV as the type parameter's value.
  • You cannot enter a CNAME record as this parameter's value if you use SRV as the  type parameter's value.


A valid hostname. subdomain.example.com
weightinteger

A relative weight. The system uses this value to rank entries with the same priority value.

Note
titleNote:

This parameter is required if you use SRV as the type parameter's value.


A positive integer that represents the target host's weight against other hosts with the same priority value. 1
portinteger

The target host's port.

Note
titleNote:

This parameter is required if you use SRV as the type parameter's value.


A positive integer that represents a port number.

Note
titleNote:

For a complete list of ports, read our How to Configure Your Firewall for cPanel Services documentation.


443
priorityinteger

The service record's  priority value .

Note
titleNote:

This parameter is required if you use SRV as the type parameter's value.


A positive integer that represents the target host's priority order .1
cnamestring

The record's canonical name.

Note
titleNote:
This parameter is required if you use cname as the type parameter's value.


A valid canonical name.example.com
addressstring

The IP address to map to the record.

Note
titleNote:
This parameter is required if you use A or AAAA as the type parameter's value.


A valid IPv4 or IPv6 address.10.10.10.10
flaginteger

Whether the CA will issue an SSL certificate.

Note
titleNotes:
  • This parameter is required if you use CAA as the type parameter's value.
  • For more information about CAA record flags, read the  RFC 6844  documentation.
  • We added this parameter in cPanel & WHM version 66.


  • 0 — Non-critical. If the CAA Resource Record contains unknown property tags, the CA will issue an SSL certificate.
  • 1 — Critical. If the CAA Resource Record contains unknown property tags, the CA will not issue an SSL certificate.
0
tagstring

The CAA record's property type.

Note
titleNotes:
  • This parameter is required if you use CAA as the type parameter's value.
  • We added this parameter in cPanel & WHM version 66.


  • issue — Authorize a CA to issue a certificate for the domain.
  • issuewild — Authorize a CA to issue a wildcard certificate for the domain.
  • iodef  — Specify a URL to which a CA may report policy violations.

issue
valuestring

The CA's domain or URL.

Note
titleNotes:
  • This parameter is required if you pass CAA as the type parameter's value.
  • Enter a URL that a CA can use to report issues as this parameter's value if you use iodef as the tag parameter's value.
  • We added this parameter in cPanel & WHM version 68.


totallyrealca.ca
ttlinteger

The record's time to live (TTL).

This value defaults to 14400.

A valid positive integer that represents the record's TTL, in seconds.14400
classstring

The record's class.

This value defaults to IN.

ININ
preferenceinteger

The mail exchanger's priority value .  

Note
titleNote:
  • Use this parameter if you pass MX as the type parameter's value.
  • We added this parameter in cPanel & WHM version 62.

This value defaults to 0.

A positive integer.

Note
titleNote:

We recommend that you set the priority value to a number divisible by five.


15
exchangestring

The mail exchanger's name.

Note
titleNote:
  • Use this parameter if you pass MX as the type parameter's value.
  • We added this parameter in cPanel & WHM version 62.

This value defaults to an empty string.

A valid mail exchanger on the cPanel account.mail.example.com

Returns

Return TypeDescriptionPossible valuesExample
resulthashA hash of the zone record information.The hash includes the newserialstatusmsg, and status returns. 

newserial

integer

The zone file's new serial number.

The function returns this value in the result hash.

A positive integer.
2014101603

statusmsg

string

A status message from the DNS server.

The function returns this value in the result hash.

A string.


Expand
titleClick to view...
Bind reloading on hostname using rndc zone: [example.com]\n


status

Boolean

Whether the function succeeded.

The function returns this value in the result hash.

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

A reason for failure.

Note
titleNote:

This function only returns a reason value if it failed.


A string that describes the error.

This is an error message.
resultBoolean

Whether the function succeeded.

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