Skip to content
Start here

Update DNS Settings

dns.settings.zone.edit(ZoneEditParams**kwargs) -> ZoneEditResponse
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
zone_id: str

Identifier.

maxLength32
flatten_all_cnames: Optional[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.

foundation_dns: Optional[bool]

Whether to enable Foundation DNS Advanced Nameservers on the zone.

internal_dns: Optional[InternalDNS]

Settings for this internal zone.

reference_zone_id: Optional[str]

The ID of the zone to fallback to.

multi_provider: Optional[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: Optional[Nameservers]

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

ns_set: Optional[int]

Configured nameserver set to be used for this zone

maximum5
minimum1
type: Optional[Literal["cloudflare.standard", "custom.account", "custom.tenant", "custom.zone"]]

Nameserver type

One of the following:
"cloudflare.standard"
"custom.account"
"custom.tenant"
"custom.zone"
ns_ttl: Optional[float]

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

maximum86400
minimum30
secondary_overrides: Optional[bool]

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

soa: Optional[SOA]

Components of the zone’s SOA record.

expire: Optional[float]

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

maximum2419200
minimum86400
min_ttl: Optional[float]

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

maximum86400
minimum60
mname: Optional[str]

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

refresh: Optional[float]

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

maximum86400
minimum600
retry: Optional[float]

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

maximum86400
minimum600
rname: Optional[str]

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

ttl: Optional[float]

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

maximum86400
minimum300
zone_mode: Optional[Literal["standard", "cdn_only", "dns_only"]]

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

One of the following:
"standard"
"cdn_only"
"dns_only"
ReturnsExpand Collapse
class ZoneEditResponse:
flatten_all_cnames: 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.

foundation_dns: bool

Whether to enable Foundation DNS Advanced Nameservers on the zone.

internal_dns: InternalDNS

Settings for this internal zone.

reference_zone_id: Optional[str]

The ID of the zone to fallback to.

multi_provider: 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: Nameservers

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

type: Literal["cloudflare.standard", "custom.account", "custom.tenant", "custom.zone"]

Nameserver type

One of the following:
"cloudflare.standard"
"custom.account"
"custom.tenant"
"custom.zone"
ns_set: Optional[int]

Configured nameserver set to be used for this zone

maximum5
minimum1
ns_ttl: float

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

maximum86400
minimum30
secondary_overrides: bool

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

soa: SOA

Components of the zone’s SOA record.

expire: Optional[float]

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

maximum2419200
minimum86400
min_ttl: Optional[float]

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

maximum86400
minimum60
mname: Optional[str]

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

refresh: Optional[float]

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

maximum86400
minimum600
retry: Optional[float]

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

maximum86400
minimum600
rname: Optional[str]

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

ttl: Optional[float]

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

maximum86400
minimum300
zone_mode: Literal["standard", "cdn_only", "dns_only"]

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

One of the following:
"standard"
"cdn_only"
"dns_only"

Update DNS Settings

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
response = client.dns.settings.zone.edit(
    zone_id="023e105f4ecef8ad9ca31a8372d0c353",
)
print(response.multi_provider)
{
  "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"
  }
}