Skip to content
Start here

Email Routing - DNS settings

client.EmailRouting.DNS.Get(ctx, params) (*[]DNSRecord, error)
GET/zones/{zone_id}/email/routing/dns

Show the DNS records needed to configure your Email Routing zone.

Security

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 Settings WriteZone Settings Read
ParametersExpand Collapse
params DNSGetParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Subdomain param.Field[string]Optional

Query param: Deprecated. When supplied, the response shape differs from the documented default and is not modeled in generated SDKs. Do not rely on this parameter.

ReturnsExpand Collapse
type DNSGetResponseEnvelopeResult []DNSRecord
Content stringOptional

DNS record content.

Name stringOptional

DNS record name (or @ for the zone apex).

maxLength255
Priority float64Optional

Required for MX, SRV and URI records. Unused by other record types. Records with lower priorities are preferred.

maximum65535
minimum0
TTL DNSRecordTTLOptional

Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for ‘automatic’.

One of the following:
float64
type DNSRecordTTL float64

Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 for ‘automatic’.

Type DNSRecordTypeOptional

DNS record type.

One of the following:
const DNSRecordTypeA DNSRecordType = "A"
const DNSRecordTypeAAAA DNSRecordType = "AAAA"
const DNSRecordTypeCNAME DNSRecordType = "CNAME"
const DNSRecordTypeHTTPS DNSRecordType = "HTTPS"
const DNSRecordTypeTXT DNSRecordType = "TXT"
const DNSRecordTypeSRV DNSRecordType = "SRV"
const DNSRecordTypeLOC DNSRecordType = "LOC"
const DNSRecordTypeMX DNSRecordType = "MX"
const DNSRecordTypeNS DNSRecordType = "NS"
const DNSRecordTypeCERT DNSRecordType = "CERT"
const DNSRecordTypeDNSKEY DNSRecordType = "DNSKEY"
const DNSRecordTypeDS DNSRecordType = "DS"
const DNSRecordTypeNAPTR DNSRecordType = "NAPTR"
const DNSRecordTypeSMIMEA DNSRecordType = "SMIMEA"
const DNSRecordTypeSSHFP DNSRecordType = "SSHFP"
const DNSRecordTypeSVCB DNSRecordType = "SVCB"
const DNSRecordTypeTLSA DNSRecordType = "TLSA"
const DNSRecordTypeURI DNSRecordType = "URI"

Email Routing - DNS settings

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  dnsRecords, err := client.EmailRouting.DNS.Get(context.TODO(), email_routing.DNSGetParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", dnsRecords)
}
{
  "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": [
    {
      "content": "route1.mx.cloudflare.net",
      "name": "example.com",
      "priority": 12,
      "ttl": 1,
      "type": "NS"
    }
  ],
  "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": [
    {
      "content": "route1.mx.cloudflare.net",
      "name": "example.com",
      "priority": 12,
      "ttl": 1,
      "type": "NS"
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}