Skip to content
Start here

Update DNS Settings

client.DNS.Settings.Zone.Edit(ctx, params) (*SettingZoneEditResponse, error)
PATCH/zones/{zone_id}/dns_settings

Update DNS settings for a zone

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Zone DNS Settings WriteDNS Write
ParametersExpand Collapse
params SettingZoneEditParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
FlattenAllCNAMEs param.Field[bool]Optional

Body param: Whether to flatten all CNAME records in the zone. Note that, due to DNS limitations, a CNAME record at the zone apex will always be flattened.

FoundationDNS param.Field[bool]Optional

Body param: Whether to enable Foundation DNS Advanced Nameservers on the zone.

InternalDNS param.Field[SettingZoneEditParamsInternalDNS]Optional

Body param: Settings for this internal zone.

ReferenceZoneID stringOptional

The ID of the zone to fallback to.

MultiProvider param.Field[bool]Optional

Body param: Whether to enable multi-provider DNS, which causes Cloudflare to activate the zone even when non-Cloudflare NS records exist, and to respect NS records at the zone apex during outbound zone transfers.

Nameservers param.Field[SettingZoneEditParamsNameservers]Optional

Body param: Settings determining the nameservers through which the zone should be available.

NSSet int64Optional

Configured nameserver set to be used for this zone

maximum5
minimum1
Type SettingZoneEditParamsNameserversTypeOptional

Nameserver type

One of the following:
const SettingZoneEditParamsNameserversTypeCloudflareStandard SettingZoneEditParamsNameserversType = "cloudflare.standard"
const SettingZoneEditParamsNameserversTypeCustomAccount SettingZoneEditParamsNameserversType = "custom.account"
const SettingZoneEditParamsNameserversTypeCustomTenant SettingZoneEditParamsNameserversType = "custom.tenant"
const SettingZoneEditParamsNameserversTypeCustomZone SettingZoneEditParamsNameserversType = "custom.zone"
NSTTL param.Field[float64]Optional

Body param: The time to live (TTL) of the zone’s nameserver (NS) records.

maximum86400
minimum30
SecondaryOverrides param.Field[bool]Optional

Body param: Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex.

SOA param.Field[SettingZoneEditParamsSOA]Optional

Body param: Components of the zone’s SOA record.

Expire float64Optional

Time in seconds of being unable to query the primary server after which secondary servers should stop serving the zone.

maximum2419200
minimum86400
MinTTL float64Optional

The time to live (TTL) for negative caching of records within the zone.

maximum86400
minimum60
MNAME stringOptional

The primary nameserver, which may be used for outbound zone transfers. If null, a Cloudflare-assigned value will be used.

Refresh float64Optional

Time in seconds after which secondary servers should re-check the SOA record to see if the zone has been updated.

maximum86400
minimum600
Retry float64Optional

Time in seconds after which secondary servers should retry queries after the primary server was unresponsive.

maximum86400
minimum600
RNAME stringOptional

The email address of the zone administrator, with the first label representing the local part of the email address.

TTL float64Optional

The time to live (TTL) of the SOA record itself.

maximum86400
minimum300
ZoneMode param.Field[SettingZoneEditParamsZoneMode]Optional

Body param: Whether the zone mode is a regular or CDN/DNS only zone.

const SettingZoneEditParamsZoneModeStandard SettingZoneEditParamsZoneMode = "standard"
const SettingZoneEditParamsZoneModeCDNOnly SettingZoneEditParamsZoneMode = "cdn_only"
const SettingZoneEditParamsZoneModeDNSOnly SettingZoneEditParamsZoneMode = "dns_only"
ReturnsExpand Collapse
type SettingZoneEditResponse struct{…}
FlattenAllCNAMEs bool

Whether to flatten all CNAME records in the zone. Note that, due to DNS limitations, a CNAME record at the zone apex will always be flattened.

FoundationDNS bool

Whether to enable Foundation DNS Advanced Nameservers on the zone.

InternalDNS SettingZoneEditResponseInternalDNS

Settings for this internal zone.

ReferenceZoneID stringOptional

The ID of the zone to fallback to.

MultiProvider bool

Whether to enable multi-provider DNS, which causes Cloudflare to activate the zone even when non-Cloudflare NS records exist, and to respect NS records at the zone apex during outbound zone transfers.

Nameservers SettingZoneEditResponseNameservers

Settings determining the nameservers through which the zone should be available.

Type SettingZoneEditResponseNameserversType

Nameserver type

One of the following:
const SettingZoneEditResponseNameserversTypeCloudflareStandard SettingZoneEditResponseNameserversType = "cloudflare.standard"
const SettingZoneEditResponseNameserversTypeCustomAccount SettingZoneEditResponseNameserversType = "custom.account"
const SettingZoneEditResponseNameserversTypeCustomTenant SettingZoneEditResponseNameserversType = "custom.tenant"
const SettingZoneEditResponseNameserversTypeCustomZone SettingZoneEditResponseNameserversType = "custom.zone"
NSSet int64Optional

Configured nameserver set to be used for this zone

maximum5
minimum1
NSTTL float64

The time to live (TTL) of the zone’s nameserver (NS) records.

maximum86400
minimum30
SecondaryOverrides bool

Allows a Secondary DNS zone to use (proxied) override records and CNAME flattening at the zone apex.

SOA SettingZoneEditResponseSOA

Components of the zone’s SOA record.

Expire float64Optional

Time in seconds of being unable to query the primary server after which secondary servers should stop serving the zone.

maximum2419200
minimum86400
MinTTL float64Optional

The time to live (TTL) for negative caching of records within the zone.

maximum86400
minimum60
MNAME stringOptional

The primary nameserver, which may be used for outbound zone transfers. If null, a Cloudflare-assigned value will be used.

Refresh float64Optional

Time in seconds after which secondary servers should re-check the SOA record to see if the zone has been updated.

maximum86400
minimum600
Retry float64Optional

Time in seconds after which secondary servers should retry queries after the primary server was unresponsive.

maximum86400
minimum600
RNAME stringOptional

The email address of the zone administrator, with the first label representing the local part of the email address.

TTL float64Optional

The time to live (TTL) of the SOA record itself.

maximum86400
minimum300
ZoneMode SettingZoneEditResponseZoneMode

Whether the zone mode is a regular or CDN/DNS only zone.

One of the following:
const SettingZoneEditResponseZoneModeStandard SettingZoneEditResponseZoneMode = "standard"
const SettingZoneEditResponseZoneModeCDNOnly SettingZoneEditResponseZoneMode = "cdn_only"
const SettingZoneEditResponseZoneModeDNSOnly SettingZoneEditResponseZoneMode = "dns_only"

Update DNS Settings

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/dns"
  "github.com/stainless-sdks/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  response, err := client.DNS.Settings.Zone.Edit(context.TODO(), dns.SettingZoneEditParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.MultiProvider)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "flatten_all_cnames": false,
    "foundation_dns": false,
    "internal_dns": {
      "reference_zone_id": "reference_zone_id"
    },
    "multi_provider": false,
    "nameservers": {
      "type": "cloudflare.standard",
      "ns_set": 1
    },
    "ns_ttl": 86400,
    "secondary_overrides": false,
    "soa": {
      "expire": 604800,
      "min_ttl": 1800,
      "mname": "kristina.ns.cloudflare.com",
      "refresh": 10000,
      "retry": 2400,
      "rname": "admin.example.com",
      "ttl": 3600
    },
    "zone_mode": "dns_only"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "flatten_all_cnames": false,
    "foundation_dns": false,
    "internal_dns": {
      "reference_zone_id": "reference_zone_id"
    },
    "multi_provider": false,
    "nameservers": {
      "type": "cloudflare.standard",
      "ns_set": 1
    },
    "ns_ttl": 86400,
    "secondary_overrides": false,
    "soa": {
      "expire": 604800,
      "min_ttl": 1800,
      "mname": "kristina.ns.cloudflare.com",
      "refresh": 10000,
      "retry": 2400,
      "rname": "admin.example.com",
      "ttl": 3600
    },
    "zone_mode": "dns_only"
  }
}