# cPanel API 2 Functions - ZoneEdit::fetchzone_records

Warning:
The cPanel API 2 system is deprecated. We **strongly** recommend that you use [UAPI](/cpanel/introduction) instead of cPanel API 2.

## Description

This function retrieves the domain's zone record modifications.

Warnings:
* We **strongly** recommend that you use [UAPI](/cpanel/introduction/) instead of cPanel API 2. However, no equivalent UAPI function exists.
* When you disable the [*DNS* role](https://docs.cpanel.net/knowledge-base/general-systems-administration/how-to-use-server-profiles/#roles),the system **disables** this function.


div
Note:

On servers that run CentOS 7, you may see a `named` warning about the
absence of SPF resource records on DNS.

- This warning is **not** relevant on CentOS 7 servers, because RFC 7208 deprecated SPF records. CentOS 7 servers use TXT records instead of SPF records.
- Red Hat 7.1 and CentOS 7.1 both contain `bind-9.9.4-23.el7`, which is an updated version of BIND that complies with RFC 7208. To resolve this issue, update your operating system to a version that contains the updated version of BIND. For more information, read the Red Hat Bugzilla case about SPF record errors.


br
## Examples

WHM API (JSON)


```undefined syntaxhighlighter-pre
https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=ZoneEdit&cpanel_jsonapi_func=fetchzone_records&domain=example.com&customonly=0&line=1&ttl=14400&name=example.com&address=10.10.10.10&type=A
```

Note:
For more information, read our [Calls from the WHM API](/whm/use-whm-api-to-call-cpanel-api-and-uapi) documentation.

LiveAPI PHP Class


```undefined syntaxhighlighter-pre
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.

// Retrieve the "example.com" domain's zone record modifications.
$fetchzone_record = $cpanel->api2(
    'ZoneEdit', 'fetchzone_records',
 array(
        'domain'    => 'example.com',
        'customonly'=> '0',
        'line'      => '1',
        'ttl'       => '14400',
        'name'      => 'example.com'
        'class'     => 'IN',
        'address'   => '10.10.10.10',
        'type'      => 'A',  
  )
);
```

Note:
For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system/#guide-to-the-liveapi-system).

LiveAPI Perl Module


```undefined syntaxhighlighter-pre
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.

# Retrieve the "example.com" domain's zone record modifications.
my $fetchzone_record = $cpliveapi->api2(
    'ZoneEdit', 'fetchzone_records',
   {
        'domain'    => 'example.com',
        'customonly'=> '0',
        'line'      => '1',
        'ttl'       => '14400',
        'name'      => 'example.com'
        'class'     => 'IN',
        'address'   => '10.10.10.10',
        'type'      => 'A',  
   }
);
```

Note:
For more information, read our [Guide to the LiveAPI System](/guides/guide-to-the-liveapi-system).

cPanel Tag System (deprecated)

Warnings:
- cPanel tags are **deprecated**. We **strongly** recommend that you **only** use the [LiveAPI](/guides/guide-to-the-liveapi-system) system to call the cPanel APIs. Examples are **only** present in order to help developers move from the old cPanel tag system to our [LiveAPI](/guides/guide-to-the-liveapi-system).
- cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
- For more information, read our [Deprecated cPanel Tag Usage](/cpanel-api-2/cpanel-api-2-deprecate-cpanel-tag-usage/) documentation.


Command Line


```undefined syntaxhighlighter-pre
cpapi2 --user=username ZoneEdit fetchzone_records domain=example.com customonly=0 line=1 ttl=14400 name=example.com class=IN address=10.10.10.10 type=A
```

div
Notes:

- You **must** URI-encode values.
- `username` represents your account-level username.
- You **must** include the `--user=username` option.
- For more information and additional output options, read our [Guide to cPanel API 2](/cpanel-api-2/) documentation or run the `cpapi2 --help` command.
- If you run CloudLinux™, you **must** use the full path of the `cpapi2` command:

```undefined syntaxhighlighter-pre
/usr/local/cpanel/bin/cpapi2
```


br
Output (JSON)


```undefined syntaxhighlighter-pre
{
    "cpanelresult": {
        "apiversion": 2,
        "func": "fetchzone_records",
        "data": [{
                "record": null,
                "Line": 1,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "; cPanel first:11.47.0.9999 (update_time):1413489769 Cpanel::ZoneFile::VERSION:1.3 hostname:laurence.dev.cpanel.net latest:11.47.0.9999",
                "line": 1
            },
            {
                "record": null,
                "Line": 2,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "; Zone file for example.com",
                "line": 2
            },
            {
                "record": null,
                "Line": 3,
                "ttl": "14400",
                "type": "$TTL",
                "line": 3
            },
            {
                "minimum": "86400",
                "ttl": "86400",
                "serial": "2014101608",
                "name": "example.com.",
                "mname": "ns1.dev.cpanel.net",
                "retry": "7200",
                "record": null,
                "refresh": "86400",
                "Line": 4,
                "Lines": 6,
                "class": "IN",
                "type": "SOA",
                "rname": "username.example.net",
                "expire": "3600000",
                "line": 4
            },
            {
                "record": null,
                "Line": 10,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "",
                "line": 10
            },
            {
                "nsdname": "ns1.dev.cpanel.net",
                "ttl": "86400",
                "name": "example.com.",
                "record": null,
                "Line": 11,
                "type": "NS",
                "class": "IN",
                "line": 11
            },
            {
                "nsdname": "ns2.dev.cpanel.net",
                "ttl": "86400",
                "name": "example.com.",
                "record": null,
                "Line": 12,
                "type": "NS",
                "class": "IN",
                "line": 12
            },
            {
                "record": null,
                "Line": 13,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "",
                "line": 13
            },
            {
                "record": null,
                "Line": 14,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "",
                "line": 14
            },
            {
                "ttl": "14400",
                "name": "example.com.",
                "record": "10.215.214.95",
                "Line": 15,
                "type": "A",
                "class": "IN",
                "address": "10.215.214.95",
                "line": 15
            },
            {
                "ttl": "14400",
                "name": "example.com.",
                "record": "2001:db8:1a34:56cf:0:0:0:0",
                "Line": 16,
                "type": "AAAA",
                "class": "IN",
                "address": "2001:db8:1a34:56cf:0:0:0:0",
                "line": 16
            },
            {
                "ttl": "14400",
                "name": "localhost.example.com.",
                "record": "127.0.0.1",
                "Line": 17,
                "type": "A",
                "class": "IN",
                "address": "127.0.0.1",
                "line": 17
            },
            {
                "ttl": "14400",
                "name": "localhost.example.com.",
                "record": "0:0:0:0:0:0:0:1",
                "Line": 18,
                "type": "AAAA",
                "class": "IN",
                "address": "0:0:0:0:0:0:0:1",
                "line": 18
            },
            {
                "record": null,
                "Line": 19,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "",
                "line": 19
            },
            {
                "ttl": "14400",
                "name": "example.com.",
                "preference": "0",
                "record": null,
                "Line": 20,
                "type": "MX",
                "class": "IN",
                "exchange": "example.com",
                "line": 20
            },
            {
                "record": null,
                "Line": 21,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "",
                "line": 21
            },
            {
                "ttl": "14400",
                "name": "mail.example.com.",
                "cname": "example.com",
                "record": "example.com",
                "Line": 22,
                "type": "CNAME",
                "class": "IN",
                "line": 22
            },
            {
                "ttl": "14400",
                "name": "www.example.com.",
                "cname": "example.com",
                "record": "example.com",
                "Line": 23,
                "type": "CNAME",
                "class": "IN",
                "line": 23
            },
            {
                "ttl": "14400",
                "name": "ftp.example.com.",
                "record": "10.215.214.95",
                "Line": 24,
                "type": "A",
                "class": "IN",
                "address": "10.215.214.95",
                "line": 24
            },
            {
                "ttl": "14400",
                "name": "ftp.example.com.",
                "record": "2001:db8:1a34:56cf:0:0:0:0",
                "Line": 25,
                "type": "AAAA",
                "class": "IN",
                "address": "2001:db8:1a34:56cf:0:0:0:0",
                "line": 25
            },
            {
                "ttl": "14400",
                "name": "fish.example.com.",
                "record": "10.215.214.95",
                "Line": 26,
                "type": "A",
                "class": "IN",
                "address": "10.215.214.95",
                "line": 26
            },
            {
                "ttl": "14400",
                "name": "fish.example.com.",
                "record": "2001:db8:1a34:56cf:0:0:0:0",
                "Line": 27,
                "type": "AAAA",
                "class": "IN",
                "address": "2001:db8:1a34:56cf:0:0:0:0",
                "line": 27
            },
            {
                "ttl": "14400",
                "name": "default._domainkey.fish.example.com.",
                "unencoded": 1,
                "record": "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDw5nw4NP1RsWXlfmiMzByDfOT16QCZO\/xJtrPZKskZF8\/sU0zWGTqKUOErlyJfoJzMDUv3\/zzjGswc2nEmYqxxoQZaBkN4QaS6MvJQxysAr+sK8C248\/r9zMperQdhJedUVejtpFQHJwgqpHy1tQMxY37L7sQjdxmQ5WnQ1acXiwIDAQAB;",
                "Line": 28,
                "txtdata": "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDw5nw4NP1RsWXlfmiMzByDfOT16QCZO\/xJtrPZKskZF8\/sU0zWGTqKUOErlyJfoJzMDUv3\/zzjGswc2nEmYqxxoQZaBkN4QaS6MvJQxysAr+sK8C248\/r9zMperQdhJedUVejtpFQHJwgqpHy1tQMxY37L7sQjdxmQ5WnQ1acXiwIDAQAB;",
                "type": "TXT",
                "class": "IN",
                "line": 28
            },
            {
                "record": null,
                "Line": 29,
                "ttl": "86400",
                "type": ":RAW",
                "raw": "",
                "line": 29
            },
            {
                "ttl": "14400",
                "name": "cpanel.example.com.",
                "record": "10.215.214.95",
                "Line": 30,
                "type": "A",
                "class": "IN",
                "address": "10.215.214.95",
                "line": 30
            },
            {
                "ttl": "14400",
                "name": "webdisk.example.com.",
                "record": "10.215.214.95",
                "Line": 31,
                "type": "A",
                "class": "IN",
                "address": "10.215.214.95",
                "line": 31
            },
            {
                "ttl": "14400",
                "name": "whm.example.com.",
                "record": "10.215.214.95",
                "Line": 32,
                "type": "A",
                "class": "IN",
                "address": "10.215.214.95",
                "line": 32
            },
            {
                "ttl": "14400",
                "name": "whm.example.com.",
                "flag": "0",
                "tag": "issue",
                "value": "totallyrealca.tld",
                "Line": 32,
                "type": "CAA",
                "class": "IN",
                "line": 32
            }
        ],
        "event": {
            "result": 1
        },
        "module": "ZoneEdit"
    }
}
```

Note:
Use cPanel's *[API Shell](https://docs.cpanel.net/cpanel/advanced/api-shell-for-cpanel)* interface (*cPanel >> Home >> Advanced >> API Shell*) to directly test cPanel API calls.

## Parameters

table
thead
tr
th
Parameter
th
strong
Type
th
strong
Description
th
strong
Possible values
th
strong
Example
tbody
tr
td
p
code
domain
td
em
string
td
p
strong
Required
p
The record's domain.
td
A valid domain name.
td
code
example.com
tr
td
p
code
customonly
td
em
Boolean
td
p
Whether to return only non-essential A and CNAME records.
p
This value defaults to 
code
0
.
td
ul
li
code
1
 — Return only non-essential records.
li
code
0
 — Return all records.
td
code
0
tr
td
p
code
line
td
em
integer
td
p
Filter results for line numbers that match this value.
p
This value defaults to 
code
1
.
td
A positive integer.
td
code
1
tr
td
p
code
ttl
td
em
integer
td
p
Filter results for time to live (TTL) values that match this value.
p
This value defaults to 
code
14400
.
td
p
A positive integer.
p
br
td
code
14400
tr
td
p
code
name
td
em
string
td
p
Filter results for DNS record name values that match this value.
p
If you do not use this parameter, the function returns all results for the domain.
td
A valid string.
td
code
example.com
tr
td
p
code
class
td
em
string
td
p
Filter results for DNS zone classes that match this value.
p
This value defaults to 
code
IN
.
td
code
IN
td
code
IN
tr
td
p
code
address
td
em
string
td
p
Filter results for IP addresses that match this value.
p
If you do not use this parameter, the function returns all of the domain's record types.
td
A valid IPv4 or IPv6 address.
td
code
10.10.10.10
tr
td
p
code
type
td
em
string
td
p
Filter results for types that match this value.
p
If you do not use this parameter, the function returns all of the domain's record types.
td
ul
li
code
A
li
code
AAAA
li
code
CAA
li
code
CNAME
li
code
MX
li
code
NS
li
code
RAW
 — This represents a blank line in the zone file.
code
li
code
SOA
li
code
SRV
li
code
                     TXT                   
td
code
A
tr
td
p
code
txtdata
td
em
string
td
p
Filter results for 
code
TXT
 values that match this value.
p
div
Note:
p
p
strong
Only
 use this parameter if you pass 
code
TXT
 as the 
code
type
 parameter's value.
br
p
This value defaults to a blank string.
td
A valid string.
td
code
v=blahblahblah
tr
td
p
code
preference
td
em
integer
td
p
Filter results for preference values that match this value.
p
div
Note:
p
p
strong
Only
 use this parameter if you pass 
code
MX
 as the 
code
type
 parameter's value.
br

This value defaults to 
code
0
.

td
An integer value.
td
code
0
tr
td
p
code
exchange
td
em
string
td
p
Filter results for 
code
MX
 values that match this value.
p
div
Note:
p
p
strong
Only
 use this parameter if you pass 
code
MX
 as the 
code
type
 parameter's value.
br
p
This value defaults to a blank string.
td
A valid hostname.
td
code
mail.example.com 
## Returns

table
thead
tr
th
strong
strong
Return
th
strong
Type
th
strong
Description
th
strong
Possible values
th
strong
Example
tbody
tr
td
code
result
td
em
hash
td
A hash of the zonefile's records.
td
The returns that each hash includes depends on the zone file's record type.
td
br
tr
td
p
code
Line
td
em
integer
td
p
The record's line in the zonefile.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer.
td
code
1
tr
td
p
code
Lines
td
em
integer
td
p
The total number of lines within the record.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer.
td
code
31
tr
td
p
code
line
td
em
integer
td
p
The record's line in the zonefile.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer.
td
code
1
tr
td
p
code
record
td
em
string
td
p
The 
code
address
, 
code
cname
, 
code
txtdata
, or 
code
raw
 content of the record.
p
The function returns this value in the 
code
result
 hash.
td
A value from the 
code
address
, 
code
cname
, 
code
txtdata
, or 
code
raw
 values.
td
(see 
code
address
, 
code
cname
, 
code
txtdata
, and 
code
raw
 values)
tr
td
p
code
mname
td
em
string
td
p
The name server record.
p
The function returns this value in the 
code
result
 hash.
td
A valid domain name.
td
code
ns1.example.com
tr
td
p
code
rname
td
em
string
td
p
A contact address for the name server record.
p
The function returns this value in the 
code
result
 hash.
td
An email address, but a period (
code
.
) that replaces the at symbol (
code
@
).
td
code
username.example.com
tr
td
p
code
retry
td
em
integer
td
p
The time between retries if the secondary name server fails to contact the master when the 
code
refresh
 period expires.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer that represents the interval in seconds.
td
br
tr
td
p
code
refresh
td
em
integer
td
p
The interval between tries when the secondary name server refreshes a non-authoritative zone from the master.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer that represents the interval in seconds.
td
code
86400
tr
td
p
code
expire
td
em
integer
td
p
The period before the secondary name server marks the zone as no longer authoritative and tries to refresh the data.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer that represents the interval in seconds.
td
code
3600000
tr
td
p
code
ttl
td
em
integer
td
p
The record's time to live.
p
The function returns this value in the 
code
result
 hash.
td
A positive integer that represents the interval in seconds.
td
code
14400
tr
td
p
code
txtdata
td
em
string
td
p
The record's text data.
p
The function returns this value in the 
code
result
 hash.
td
The contents of a DKIM, SPF, or other TXT-based record.
td
code
v=blahblahblah
tr
td
p
code
uuencode
td
em
Boolean
td
p
Whether the record is uuencoded.
p
The function returns this value in the 
code
result
 hash.
td
ul
li
code
1
 — Uuencoded.
li
code
0
 — 
strong
Not
 uuencoded.
td
code
1
tr
td
p
code
raw
td
em
string
td
p
The record's raw output.
p
The function returns this value in the 
code
result
 hash.
td
A valid string.
td
code
v=blahblahblah
tr
td
p
code
cname
td
em
string
td
p
The record's canonical name.
p
The function returns this value in the 
code
result
 hash.
td
A valid hostname.
td
code
hostname.example.com
tr
td
p
code
address
td
em
string
td
p
The record's IP address.
p
The function returns this value in the 
code
result
 hash.
td
span
A valid IPv4 or IPv6 address.
td
code
192.168.0.1
tr
td
p
code
class
td
em
string
td
p
The record's class.
p
The function returns this value in the 
code
result
 hash.
td
code
IN
td
code
IN
tr
td
p
code
type
td
em
string
td
p
The record's type.
p
The function returns this value in the 
code
result
 hash.
td
p
The most common results will be the following:
ul
li
code
A
li
code
AAAA
li
code
CAA
li
code
CNAME
li
code
MX
li
code
NS
li
code
RAW
 — This represents a blank line in the zone record.
code
li
code
SOA
li
code
SRV
li
code
TXT
td
code
A
tr
td
p
code
name
td
em
string
td
p
The record's name, which will map to the subdomain.
p
The function returns this value in the 
code
result
 hash.
td
A valid subdomain.
td
code
hostname.example.com
tr
td
p
code
txtdata
td
em
string
td
p
If the 
code
type
 return's value is 
code
TXT
, the record's text data.
p
The function returns this value in the 
code
result
 hash.
td
A valid string.
td
code
v=blahblahblah
tr
td
p
code
cname
td
em
string
td
p
If the 
code
type
 return's value is 
code
CNAME
, the record's canonical name.
p
The function returns this value in the 
code
result
 hash.
td
A valid string.
td
code
hostname.example.com
tr
td
p
code
exchange
td
em
string
td
p
If the 
code
type
 return's value is 
code
MX
, the mail exchange's hostname.
p
The function returns this value in the 
code
result
 hash.
td
A valid hostname.
td
code
mail.example.com
tr
td
p
code
nsdname
td
em
string
td
p
If the 
code
type
 return's value is 
code
NS
, the authoritative nameserver's hostname.
p
The function returns this value in the 
code
result
 hash.
td
A valid hostname.
td
code
ns1.example.com
tr
td
p
code
preference
td
em
integer
td
p
If the 
code
type
 return's value is 
code
MX
, the priority of the mail exchanger.
p
span
The function returns this value in the
code
result
span
hash.
td
A valid integer, where smaller numbers represent higher priority mail exchanges.
td
code
1
tr
td
p
code
flag
td
em
integer
td
p
span
If the 
code
type
span
 return's value is 
code
CAA
span
, whether the CA will issue an SSL certificate if the CAA Resource Record contains unknown property tags.
p
div
Note:
p
ul
li
For more information about CAA record flags, read the 
a
RFC 6844
 documentation.
li
We added this return in cPanel 
&
 WHM version 66.
br
td
ul
li
code
0
 — Non-critical. The CAA Resource Record contains unknown property tags, and the CA issued an SSL certificate.
li
code
1
 — Critical. The CAA Resource Record contains unknown property tags, and the CA did 
strong
not 
issue an SSL certificate.
td
code
0
tr
td
p
code
tag
td
em
string
td
p
span
If the 
code
type
span
 return's value is 
span
CAA
span
, the CAA record's property type.
p
div
Note:
p
p
We added this return in cPanel 
&
 WHM version 68.
br

The function returns this value in the 
code
result
 hash.

td
ul
li
code
issue
 — A CA issued a certificate for the domain.
li
code
issuewild
 — A CA issued a wildcard certificate for the domain.
li
p
code
iodef
em
— The user specified a URL to which a CA may report policy violations.
td
code
issue
tr
td
p
code
value
td
em
string
td
p
span
If the 
code
type
span
 return's value is 
code
CAA
span
, the CA's domain or URL.
p
div
Note:
p
p
We added this return in cPanel 
&
 WHM version 66.
br

The function returns this value in the 
code
result
 hash.

td
ul
li
A valid 
a
SSL provider
.
li
A mailto URL or a standard URL.
td
code
totallyrealca.tld
tr
td
p
code
priority
td
em
integer
td
p
If the 
code
type
 return's value is 
code
SRV
, the service record's 
a
priority value
.
p
The 
span
function returns this value in the 
code
result
span
 hash.
td
span
A positive integer 
span
that represents the target host's priority order
span
.
td
code
1
tr
td
p
code
weight
td
em
integer
td
p
If the 
code
type
 return's value is 
code
SRV
, the value that the system uses to rank entries with the same 
code
priority
 value.
p
The 
span
function returns this value in the 
code
result
span
 hash.
td
span
A positive integer that represents the target host's weight against other hosts with the same 
code
priority
span
 value.
td
code
1
tr
td
p
code
port
td
em
integer
td
p
If the 
code
type
 return's value is 
code
SRV
, the target host's port.
p
The 
span
function returns this value in the 
code
result
span
 hash.
td
span
A positive integer that represents a port number.
td
code
443
tr
td
p
code
target
td
em
integer
td
p
If the 
code
type
 return's value is 
code
SRV
, the service's target host.
p
The 
span
function returns this value in the 
code
result
span
 hash.
td
A valid hostname.
td
code
subdomain.example.com
tr
td
code
reason
td
em
string
td
p
A reason for failure.
p
div
Note:
p
p
This function only returns a 
code
reason
 value if it failed.
br
td
p
A string that describes the error.
td
code
This is an error message.
tr
td
code
result
td
em
Boolean
td
p
Whether the function succeeded.
td
ul
li
code
1
 — The function succeeded.
li
code
0
 — The function failed.
td
code
1