# cPanel API 2 Functions - ZoneEdit::edit_zone_record 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 edits a zone record. 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. ## Examples WHM API (JSON) ``` 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 ``` 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 ``` $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', ) ); ``` 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 ``` 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', } ); ``` 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 ``` 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 ``` 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: ``` /usr/local/cpanel/bin/cpapi2 ``` br Output (JSON) ``` { "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" } } ``` 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 Parameters th strong Type th strong Description th strong Possible values th strong Example tbody tr td code line td em integer td p strong Required p The line in the zone file to edit. td A positive integer. td code 5 tr td 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 code name td em string td p strong Required p The record's name, which maps to the subdomain. td A valid string. td code sub tr td code type td em string td p strong Required p The record type. td ul li code A li code AAAA li code CAA li code CNAME li code MX div Note: 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*](https://docs.cpanel.net/whm/packages/feature-manager/) interface (WHM >> Home >> Packages >> Feature Manager): ul li em Ability to Change MX li em Zone Editor (AAAA, CAA, SRV, TXT) li code SRV li code TXT td code A tr td code txtdata td em string td p The record's text data. p div Note: p This parameter is strong required if you use code TXT as the code type parameter's value. br td A valid string. td code v=blahblahblah tr td code target td em string td p span The service's target host. div Notes: ul li This parameter is strong required if you use code SRV as the code type parameter's value. li You strong cannot enter a CNAME record as this parameter's value span if you use code SRV span as the code type span parameter's value. br td span A valid hostname. td code subdomain.example.com tr td code weight td em integer td p span A relative weight. The system uses this value to rank entries with the same code priority span value. p div Note: p This parameter is strong required if you use code SRV as the code type parameter's value. br 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 code port td em integer td p span The target host's port. p div Note: p This parameter is strong required if you use code SRV as the code type parameter's value. br td p A positive integer thats represents a port number. div Note: For a complete list of ports, read our [How to Configure Your Firewall for cPanel Services](https://docs.cpanel.net/knowledge-base/general-systems-administration/how-to-configure-your-firewall-for-cpanel-services/) documentation. td code 443 tr td code priority td em integer td p span The service record's a priority value . p div Note: p This parameter is strong required if you use code SRV as the code type parameter's value. br td span A positive integer span that represents the target host's priority order span . td code 1 tr td code cname td em string td p The record's canonical name. p div Note: p This parameter is strong required if you use code cname as the code type parameter's value. br td A valid canonical name. td code example.com tr td code address td em string td p The IP address to map to the record. p div Note: p This parameter is strong required if you use code A or code AAAA as the code type parameter's value. br td A valid IPv4 or IPv6 address. td code 10.10.10.10 tr td code flag td em integer td p Whether the CA will issue an SSL certificate. div Notes: ul li This parameter is strong required if you use code CAA as the code type parameter's value. li span For more information about CAA record flags, read the a RFC 6844 span documentation. li We added this parameter in cPanel & WHM version 66. br td ul li code 0 — Non-critical. If the CAA Resource Record contains unknown property tags, the CA will issue an SSL certificate. li code 1 — Critical. If the CAA Resource Record contains unknown property tags, the CA will strong not issue an SSL certificate. td code 0 tr td code tag td em string td p span The CAA record's property type. div Notes: ul li This parameter is strong required if you use code CAA as the code type parameter's value. li We added this parameter in cPanel & WHM version 66. br td ul li code issue — Authorize a CA to issue a certificate for the domain. li code issuewild — Authorize a CA to issue a wildcard certificate for the domain. li p code iodef em — Specify a URL to which a CA may report policy violations. td code issue tr td code value td em string td p span The CA's domain or URL. div Notes: ul li This parameter is strong required if you pass code CAA as the code type parameter's value. li Enter a URL that a CA can use to report issues as this parameter's value if you use code iodef as the code tag parameter's value. li We added this parameter in cPanel & WHM version 68. br td ul li A valid a SSL provider . li A mailto URL or a standard URL. td code totallyrealca.ca tr td code ttl td em integer td p The record's time to live (TTL). p This value defaults to code 14400 . td A valid positive integer that represents the record's TTL, in seconds. td code 14400 tr td code class td em string td p The record's class. p This value defaults to code IN . td code IN td code IN tr td code preference td em integer td p The mail exchanger's a priority value . div Note: ul li Use this parameter if you pass code MX as the code type parameter's value. li We added this parameter in cPanel & WHM version 62. br p This value defaults to code 0 . td p A positive integer. p div Note: p We recommend that you set the priority value to a number divisible by five. br td code 15 tr td code exchange td em string td p The mail exchanger's name. div Note: ul li Use this parameter if you pass code MX as the code type parameter's value. li We added this parameter in cPanel & WHM version 62. br p This value defaults to an empty string. td A valid mail exchanger on the cPanel account. td code mail.example.com ## Returns table colgroup col col col col col 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 zone record information. td The hash includes the code newserial , code statusmsg , and code status returns. td tr td p code newserial td em integer td p The zone file's new serial number. p The function returns this value in the code result hash. td A positive integer. td code 2014101603 tr td p code statusmsg td em string td p A status message from the DNS server. p The function returns this value in the code result hash. td A string. td code Bind reloading on hostname using rndc zone: [example.com]\n tr td p code status td em Boolean td p Whether the function succeeded. p The function returns this value in the code result hash. td ul li code 1 — The function succeeded. li code 0 — The function failed. td code 1 tr td code reason td em string td p A reason for failure. p div Note: 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