Skip to content
Start here

List DNS Records

client.DNS.Records.List(ctx, params) (*V4PagePaginationArray[RecordResponse], error)
GET/zones/{zone_id}/dns_records

List, search, sort, and filter a zones' DNS records.

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)
DNS ReadDNS Write
ParametersExpand Collapse
params RecordListParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Comment param.Field[RecordListParamsComment]optional

Query param

Absent stringoptional

If this parameter is present, only records without a comment are returned.

Contains stringoptional

Substring of the DNS record comment. Comment filters are case-insensitive.

Endswith stringoptional

Suffix of the DNS record comment. Comment filters are case-insensitive.

Exact stringoptional

Exact value of the DNS record comment. Comment filters are case-insensitive.

Present stringoptional

If this parameter is present, only records with a comment are returned.

Startswith stringoptional

Prefix of the DNS record comment. Comment filters are case-insensitive.

Content param.Field[RecordListParamsContent]optional

Query param

Contains stringoptional

Substring of the DNS record content. Content filters are case-insensitive.

Endswith stringoptional

Suffix of the DNS record content. Content filters are case-insensitive.

Exact stringoptional

Exact value of the DNS record content. Content filters are case-insensitive.

Startswith stringoptional

Prefix of the DNS record content. Content filters are case-insensitive.

Direction param.Field[SortDirection]optional

Query param: Direction to order DNS records in.

Match param.Field[RecordListParamsMatch]optional

Query param: Whether to match all search requirements or at least one (any). If set to all, acts like a logical AND between filters. If set to any, acts like a logical OR instead. Note that the interaction between tag filters is controlled by the tag-match parameter instead.

const RecordListParamsMatchAny RecordListParamsMatch = "any"
const RecordListParamsMatchAll RecordListParamsMatch = "all"
Name param.Field[RecordListParamsName]optional

Query param

Contains stringoptional

Substring of the DNS record name. Name filters are case-insensitive.

Endswith stringoptional

Suffix of the DNS record name. Name filters are case-insensitive.

Exact stringoptional

Exact value of the DNS record name. Name filters are case-insensitive.

Startswith stringoptional

Prefix of the DNS record name. Name filters are case-insensitive.

Order param.Field[RecordListParamsOrder]optional

Query param: Field to order DNS records by.

const RecordListParamsOrderType RecordListParamsOrder = "type"
const RecordListParamsOrderName RecordListParamsOrder = "name"
const RecordListParamsOrderContent RecordListParamsOrder = "content"
const RecordListParamsOrderTTL RecordListParamsOrder = "ttl"
const RecordListParamsOrderProxied RecordListParamsOrder = "proxied"
Page param.Field[float64]optional

Query param: Page number of paginated results.

minimum1
PerPage param.Field[float64]optional

Query param: Number of DNS records per page.

maximum5000000
minimum1
Proxied param.Field[bool]optional

Query param: Whether the record is receiving the performance and security benefits of Cloudflare.

Tag param.Field[RecordListParamsTag]optional

Query param

Absent stringoptional

Name of a tag which must not be present on the DNS record. Tag filters are case-insensitive.

Contains stringoptional

A tag and value, of the form <tag-name>:<tag-value>. The API will only return DNS records that have a tag named <tag-name> whose value contains <tag-value>. Tag filters are case-insensitive.

Endswith stringoptional

A tag and value, of the form <tag-name>:<tag-value>. The API will only return DNS records that have a tag named <tag-name> whose value ends with <tag-value>. Tag filters are case-insensitive.

Exact stringoptional

A tag and value, of the form <tag-name>:<tag-value>. The API will only return DNS records that have a tag named <tag-name> whose value is <tag-value>. Tag filters are case-insensitive.

Present stringoptional

Name of a tag which must be present on the DNS record. Tag filters are case-insensitive.

Startswith stringoptional

A tag and value, of the form <tag-name>:<tag-value>. The API will only return DNS records that have a tag named <tag-name> whose value starts with <tag-value>. Tag filters are case-insensitive.

TagMatch param.Field[RecordListParamsTagMatch]optional

Query param: Whether to match all tag search requirements or at least one (any). If set to all, acts like a logical AND between tag filters. If set to any, acts like a logical OR instead. Note that the regular match parameter is still used to combine the resulting condition with other filters that aren't related to tags.

const RecordListParamsTagMatchAny RecordListParamsTagMatch = "any"
const RecordListParamsTagMatchAll RecordListParamsTagMatch = "all"
Type param.Field[RecordListParamsType]optional

Query param: Record type.

const RecordListParamsTypeA RecordListParamsType = "A"
const RecordListParamsTypeAAAA RecordListParamsType = "AAAA"
const RecordListParamsTypeCAA RecordListParamsType = "CAA"
const RecordListParamsTypeCERT RecordListParamsType = "CERT"
const RecordListParamsTypeCNAME RecordListParamsType = "CNAME"
const RecordListParamsTypeDNSKEY RecordListParamsType = "DNSKEY"
const RecordListParamsTypeDS RecordListParamsType = "DS"
const RecordListParamsTypeHTTPS RecordListParamsType = "HTTPS"
const RecordListParamsTypeLOC RecordListParamsType = "LOC"
const RecordListParamsTypeMX RecordListParamsType = "MX"
const RecordListParamsTypeNAPTR RecordListParamsType = "NAPTR"
const RecordListParamsTypeNS RecordListParamsType = "NS"
const RecordListParamsTypeOpenpgpkey RecordListParamsType = "OPENPGPKEY"
const RecordListParamsTypePTR RecordListParamsType = "PTR"
const RecordListParamsTypeSMIMEA RecordListParamsType = "SMIMEA"
const RecordListParamsTypeSRV RecordListParamsType = "SRV"
const RecordListParamsTypeSSHFP RecordListParamsType = "SSHFP"
const RecordListParamsTypeSVCB RecordListParamsType = "SVCB"
const RecordListParamsTypeTLSA RecordListParamsType = "TLSA"
const RecordListParamsTypeTXT RecordListParamsType = "TXT"
const RecordListParamsTypeURI RecordListParamsType = "URI"
ReturnsExpand Collapse
type RecordResponse interface{…}
One of the following:
type RecordResponseA struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseAAAA struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseCNAME struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseMX struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseNS struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseOpenpgpkey struct{…}
ID string

Identifier.

maxLength32
Comment string

Comments or notes about the DNS record. This field has no effect on DNS responses.

Content string

A single Base64-encoded OpenPGP Transferable Public Key (RFC 4880 Section 11.1)

CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Name string

Complete DNS record name, including the zone name, in Punycode.

maxLength255
minLength1
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

Proxied bool

Whether the record is receiving the performance and security benefits of Cloudflare.

Settings RecordResponseOpenpgpkeySettings

Settings for the DNS record.

IPV4Only booloptional

When enabled, only A records will be generated, and AAAA records will not be created. This setting is intended for exceptional cases. Note that this option only applies to proxied records and it has no effect on whether Cloudflare communicates with the origin using IPv4 or IPv6.

IPV6Only booloptional

When enabled, only AAAA records will be generated, and A records will not be created. This setting is intended for exceptional cases. Note that this option only applies to proxied records and it has no effect on whether Cloudflare communicates with the origin using IPv4 or IPv6.

Tags []RecordTags

Custom tags for the DNS record. This field has no effect on DNS responses.

TTL TTL

Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. Value must be between 60 and 86400, with the minimum reduced to 30 for Enterprise zones.

One of the following:
float64
type TTL float64

Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. Value must be between 60 and 86400, with the minimum reduced to 30 for Enterprise zones.

Type RecordResponseOpenpgpkeyType

Record type.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponsePTR struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseTXT struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseCAA struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseCERT struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseDNSKEY struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseDS struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseHTTPS struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseLOC struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseNAPTR struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseSMIMEA struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseSRV struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseSSHFP struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseSVCB struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseTLSA struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time
type RecordResponseURI struct{…}
ID string

Identifier.

maxLength32
CreatedOn Time

When the record was created.

formatdate-time
Meta unknown

Extra Cloudflare-specific information about the record.

ModifiedOn Time

When the record was last modified.

formatdate-time
Proxiable bool

Whether the record can be proxied by Cloudflare or not.

CommentModifiedOn Timeoptional

When the record comment was last modified. Omitted if there is no comment.

formatdate-time
TagsModifiedOn Timeoptional

When the record tags were last modified. Omitted if there are no tags.

formatdate-time

List DNS Records

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  page, err := client.DNS.Records.List(context.TODO(), dns.RecordListParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "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": [
    {
      "name": "example.com",
      "ttl": 3600,
      "type": "A",
      "comment": "Domain verification record",
      "content": "198.51.100.4",
      "private_routing": true,
      "proxied": true,
      "settings": {
        "ipv4_only": true,
        "ipv6_only": true
      },
      "tags": [
        "owner:dns-team"
      ],
      "id": "023e105f4ecef8ad9ca31a8372d0c353",
      "created_on": "2014-01-01T05:20:00.12345Z",
      "meta": {},
      "modified_on": "2014-01-01T05:20:00.12345Z",
      "proxiable": true,
      "comment_modified_on": "2024-01-01T05:20:00.12345Z",
      "tags_modified_on": "2025-01-01T05:20:00.12345Z"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}
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": [
    {
      "name": "example.com",
      "ttl": 3600,
      "type": "A",
      "comment": "Domain verification record",
      "content": "198.51.100.4",
      "private_routing": true,
      "proxied": true,
      "settings": {
        "ipv4_only": true,
        "ipv6_only": true
      },
      "tags": [
        "owner:dns-team"
      ],
      "id": "023e105f4ecef8ad9ca31a8372d0c353",
      "created_on": "2014-01-01T05:20:00.12345Z",
      "meta": {},
      "modified_on": "2014-01-01T05:20:00.12345Z",
      "proxiable": true,
      "comment_modified_on": "2024-01-01T05:20:00.12345Z",
      "tags_modified_on": "2025-01-01T05:20:00.12345Z"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}