schedule 15-min read

How to Add a DMARC Record in Cloudflare DNS

DMARC AI editorial team · Last updated

Add a Cloudflare DMARC record at _dmarc in the dashboard, with the API or Terraform, and see what DMARC Management and Email Routing change in the zone.

01

How do you add a DMARC record in Cloudflare?

To add a Cloudflare DMARC record, open the domain in the Cloudflare dashboard, go to DNS > Records > Add record, choose type TXT, enter _dmarc as the name and paste a value such as v=DMARC1; p=none; rua=mailto:reports@example.net. Save it. TXT records are always DNS only, so there is no proxy setting to decide.

This guide covers the dashboard steps, the Cloudflare API and Terraform, and what Cloudflare's own DMARC Management and Email Routing features change in a zone. DMARC (Domain-based Message Authentication, Reporting and Conformance) builds on SPF (Sender Policy Framework) and DKIM (DomainKeys Identified Mail). It also covers subdomains, multi-zone MSP (managed service provider) accounts and verification. For the protocol itself, start with the DMARC guide. If the zone is hosted in Microsoft Azure instead, follow adding a DMARC record in Azure DNS.

02

Key takeaways

  • The record is a TXT record named _dmarc in the zone of the domain it protects. Cloudflare appends the zone name.
  • TXT records cannot be proxied. Only A, AAAA and CNAME records can, so the orange cloud plays no part in DMARC.
  • Enabling Cloudflare DMARC Management adds a Cloudflare rua address to an existing record. Your current report address stays, because rua accepts a comma-separated list.
  • One name, one DMARC record. Under RFC 9989, receivers discard all of them when more than one is returned.
  • For client portfolios, use API tokens scoped to specific zones and domain-scoped member roles instead of shared logins.
03

Is the domain's DNS actually hosted on Cloudflare?

Check delegation before you edit anything. A Cloudflare zone only answers on the internet when the registrar points the domain at the two Cloudflare name servers assigned to it. A zone that was added but never activated accepts your records and serves them to nobody.

$ dig +short NS example.com
ada.ns.cloudflare.com.
bob.ns.cloudflare.com.

If the answer shows another provider, the live zone is somewhere else, which is common in inherited client estates. If the name servers belong to a web host, the zone is often managed in cPanel, covered in how to add a DMARC record in cPanel. If they end in domaincontrol.com, the zone is at GoDaddy, and how to add a DMARC record in GoDaddy DNS applies. Our DNS lookup tool shows the same answer without a terminal. Note that Cloudflare's DMARC Management feature only works with apex domains, not subdomain setups, as its enablement guide states.

04

How do you add the DMARC record in the Cloudflare dashboard?

Select the account and domain, open DNS > Records, select Add record, set the type to TXT, the name to _dmarc, leave TTL on Auto and paste the DMARC value into Content. Select Save. Cloudflare's own Google Workspace setup guide uses the same name and type for its DMARC step.

  1. Log in to the Cloudflare dashboard and select the account, then the domain (for example example.com).
  2. Go to DNS > Records and select Add record.
  3. Type: TXT.
  4. Name: _dmarc. Cloudflare adds the zone, so the record becomes _dmarc.example.com.
  5. TTL: Auto is fine. Choose a short fixed value, such as 5 minutes, if you plan a policy change soon.
  6. Content: the full DMARC string on one line.
  7. Select Save.

A first record for a client in monitoring mode:

v=DMARC1; p=none; rua=mailto:dmarc-reports@example.net

You do not need to type quotes. Cloudflare's DNS record types reference says that if you save new TXT content without quotes, Cloudflare adds the double quotes automatically. If you are unsure of the syntax, the DMARC record generator builds a valid value, and how to create a DMARC record step by step explains each tag.

Does proxy status matter for a DMARC TXT record?

No. Cloudflare can only proxy the records that resolve to addresses: A, AAAA and CNAME. TXT and MX records are always DNS only, and the dashboard shows no proxy toggle for them. Receivers query _dmarc directly and get the text you saved, so there is nothing to switch off.

05

How do you add a DMARC record with the Cloudflare API?

Send POST /zones/{zone_id}/dns_records to the Cloudflare API v4 with a bearer token that holds DNS write permission for that zone. The body sets type to TXT, name to _dmarc.example.com and content to the DMARC string. A ttl of 1 means automatic. The fields are documented in Create DNS Record.

curl https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records 
  -H 'Content-Type: application/json' 
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" 
  -d '{
    "type": "TXT",
    "name": "_dmarc.example.com",
    "content": ""v=DMARC1; p=none; rua=mailto:dmarc-reports@example.net"",
    "ttl": 1,
    "comment": "DMARC monitoring, change ticket 4821"
  }'

The API docs describe content as quoted character strings, so the example wraps the value in escaped double quotes. The comment field has no effect on DNS answers, but it gives the next engineer a reason and a ticket number.

Before you create anything, check whether a record already exists. A second POST does not replace the first: it adds a second TXT record at the same name.

curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?type=TXT&name.exact=_dmarc.example.com" 
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"

If a record comes back, take its id and change it with PATCH /zones/{zone_id}/dns_records/{dns_record_id} instead of creating another one.

Which API token permissions does the call need?

Create a token from the Edit zone DNS template and limit its zone resources to the specific client zone. Listing records needs DNS Read; creating or updating them needs DNS Write. Cloudflare's create token guide also lets you set an expiry date and restrict the token to client IP addresses.

Task Permission Resource scope
Read the current _dmarc record Zone, DNS, Read One specific zone
Create or change the record Zone, DNS, Edit (DNS Write in the API reference) One specific zone
Script across a client's several zones Zone, DNS, Edit Only that client's zones

Avoid the legacy Global API Key for this work. It carries every permission the user has, across every account they can reach.

06

Can you manage the DMARC record with Terraform?

Yes, and it suits MSPs that already keep client DNS in code. In the current Cloudflare provider the resource is cloudflare_dns_record, with zone_id, name, type and ttl required. Older provider versions used cloudflare_record, so check which version a repository pins before copying examples between projects.

resource "cloudflare_dns_record" "dmarc_example_com" {
  zone_id = var.zone_id_example_com
  name    = "_dmarc.example.com"
  type    = "TXT"
  ttl     = 1
  content = ""v=DMARC1; p=none; rua=mailto:dmarc-reports@example.net""
  comment = "Managed by Terraform"
}

If the record already exists in the dashboard, import it into state before applying, otherwise Terraform creates a duplicate. Once a record is managed in code, make every later change there too, or the next terraform apply quietly reverts a dashboard edit.

07

What does Cloudflare DMARC Management change in the record?

Enabling DMARC Management scans the zone for a DMARC record. If none exists, Cloudflare offers to add one. If one exists, Cloudflare adds another rua entry that uses a Cloudflare email address, so it can receive and process aggregate reports and show them in the dashboard. Your existing values stay in place.

The feature sits under Email > DMARC Management in the domain's dashboard. Cloudflare's DMARC Management overview says it is available on all plans to customers using Cloudflare DNS. After setup, it shows email volume over up to 30 days, the top sources sending as the domain, and SPF, DKIM and DMARC pass or fail results per source. The first reports can take up to 24 hours to appear.

What happens if the client already sends reports to another rua address?

Both destinations keep receiving reports. RFC 9989, Section 4.7, defines rua as a comma-separated list of reporting URIs, and receivers send to each one up to their own limit. After enablement the record looks something like this, with Cloudflare's address in place of the placeholder:

v=DMARC1; p=none; rua=mailto:dmarc-reports@example.net,mailto:<cloudflare-address>

Three points matter for an MSP:

  • External verification. Any rua address on a different domain from the policy domain must be authorised by that receiving domain. RFC 9990, Section 4, has receivers look up a TXT record such as example.com._report._dmarc.example.net that starts with v=DMARC1. That record lives in the report receiver's DNS, not the client's. For your own reporting platform, see authorising external DMARC report destinations.
  • Record ownership. Cloudflare now edits a record you may also manage in Terraform or a script. Bring the new value into your source of truth, or the next apply removes Cloudflare's address.
  • Data flows. Each extra rua destination is another party receiving the client's aggregate data. Record it in the client's documentation.

If you are weighing Cloudflare's dashboard against a dedicated platform, our DMARC AI and Cloudflare DMARC Management page covers that question separately.

08

Does Cloudflare Email Routing affect DMARC?

Yes, indirectly. Enabling Email Routing adds MX records pointing at Cloudflare and an SPF TXT record, v=spf1 include:_spf.mx.cloudflare.net ~all, at the apex. It does not create or edit the _dmarc record. It also asks to delete existing MX records, and will not enable while they remain.

Read the Email Routing documentation before enabling it on a client domain that already has a mailbox provider. Practical checks:

  • SPF. The apex must still hold exactly one v=spf1 record. If the client sends through Microsoft 365 or Google Workspace, merge the includes into one record, as described in multiple SPF records: how to merge them.
  • MX. Email Routing replaces inbound mail delivery. It is meant for forwarding domains, not domains with live mailboxes.
  • DKIM. Cloudflare's postmaster documentation shows customer domains with a DKIM key at cf2024-1._domainkey. Leave it in place while Email Routing is in use.
  • Sending. Email Routing does not send outbound mail for custom addresses, so it does not add a sending source that needs DMARC alignment.

Email Routing also enforces DMARC on inbound mail: depending on the sender's policy, it rejects messages that fail authentication.

09

How do you add DMARC records for subdomains in Cloudflare?

Add another TXT record in the same zone with the name _dmarc. followed by the subdomain label, for example _dmarc.marketing for marketing.example.com. A subdomain without its own record inherits the organisational domain's sp= policy, or p= if sp= is absent, through the DNS tree walk in RFC 9989, Section 4.10.

_dmarc.example.com.            TXT  "v=DMARC1; p=reject; sp=reject; rua=mailto:dmarc-reports@example.net"
_dmarc.marketing.example.com.  TXT  "v=DMARC1; p=none; rua=mailto:dmarc-reports@example.net"

A separate record is useful when a new sending platform on a subdomain needs monitoring while the parent is already at p=reject. If the subdomain is delegated to its own Cloudflare zone, the record goes in that zone with the name _dmarc. More patterns are in DMARC record examples for common setups and DMARC for subdomains.

10

Should the Cloudflare DMARC record include pct?

No. RFC 9989 replaced RFC 7489 and removed the pct tag, and Section 4.7 says unknown tags must be ignored. Move through p=none, then p=quarantine, then p=reject, each in full, once aggregate reports show every legitimate sender passing with alignment. For a cautious step, add t=y, which asks receivers to apply the next lower policy:

v=DMARC1; p=quarantine; t=y; rua=mailto:dmarc-reports@example.net

Remove t=y when the level is confirmed. The UK NCSC email security and anti-spoofing guidance follows the same principle of starting at none and using reports before enforcing.

11

How should MSPs manage DMARC across many Cloudflare zones?

Give each engineer and each script the least access needed, per client. Cloudflare supports member policies scoped to specific domains or domain groups, using domain-scoped roles such as Domain DNS, which grants access to edit DNS settings. Pair that with API tokens limited to named zones.

  • Accounts. Where the client owns the Cloudflare account, ask to be invited as a member rather than sharing a login. Cloudflare's role scopes let the client limit you to specific domains.
  • Roles. The account-level DNS role edits DNS records in every zone of the account. Prefer Domain DNS on named domains when a client account also holds zones you do not manage. Role names are listed on Cloudflare's account roles page.
  • Tokens. Create one token per client or per automation job, scoped to its zones, with an expiry date. Revoke it at offboarding.
  • Inventory. List every zone a token can reach and confirm each has exactly one _dmarc record. Domains without one belong on the onboarding list.
  • Change log. Record the old value, the new value and the reason for each edit. DMARC change management for MSP portfolios suggests a format.

DMARC AI collects aggregate reports for every client domain in one multi-tenant view, so you can confirm after a Cloudflare change that reports keep arriving and legitimate senders still align. More on running this as a service is on DMARC for MSPs.

12

How do you verify the record after publishing?

Query _dmarc with dig and confirm exactly one DMARC record returns with the intended value. Then check the record in DNS > Records, where filtering by _dmarc shows every TXT record at that name. Two rows there mean two records in DNS.

$ dig +short TXT _dmarc.example.com
"v=DMARC1; p=none; rua=mailto:dmarc-reports@example.net"

To avoid resolver caching, ask one of the zone's assigned Cloudflare name servers directly:

$ dig @ada.ns.cloudflare.com +short TXT _dmarc.example.com

On Windows, Resolve-DnsName -Name _dmarc.example.com -Type TXT gives the same answer. The DMARC checker validates syntax and flags duplicate records.

13

What are the common Cloudflare DMARC record mistakes?

Most failures come from the name field, duplicate records or the wrong zone, not from DMARC syntax. The table lists the usual causes in inherited Cloudflare zones and the fix for each.

Symptom Cause Fix
dig returns nothing for _dmarc.example.com Record saved as _dmarc.example.com.example.com because the full name was pasted with the zone already in it Rename the record to _dmarc and query again
Checker reports no valid policy Two TXT records at _dmarc, often one old and one new, or one added by a script Merge into one record; RFC 9989 discards all when more than one returns
Record visible in the dashboard but not on the internet Zone not active, or edited in a duplicate zone or account Check dig NS and edit the zone the registrar actually delegates to
Subdomain policy has no effect Record added in the parent zone while the subdomain is a separate Cloudflare zone Add _dmarc in the subdomain's own zone
Content shows doubled or stray quotes Value pasted with extra quote marks around or inside it Save the plain value; Cloudflare adds the outer quotes itself
Cloudflare rua address disappears Terraform or a script overwrote the record after DMARC Management edited it Add the Cloudflare address to the managed value
Reports stop at one destination rua on another domain without an authorisation record Publish the _report._dmarc record in the receiving domain
Two SPF records after Email Routing Cloudflare's SPF added beside the existing one Merge into a single v=spf1 record
14

FAQ

What name do I enter for a DMARC record in Cloudflare?

Enter _dmarc only. Cloudflare appends the zone name, so _dmarc in the example.com zone becomes _dmarc.example.com. For a subdomain in the same zone, enter _dmarc.marketing. In the API and Terraform examples on this page, the full name _dmarc.example.com is used instead.

Can I proxy a DMARC record through Cloudflare?

No. Cloudflare proxies only A, AAAA and CNAME records, the types that resolve to addresses. TXT records, including DMARC, SPF and most DKIM records, are always DNS only. Receivers read the text directly from Cloudflare's name servers, so proxy status has no effect on DMARC evaluation.

Will Cloudflare DMARC Management remove my existing rua address?

No. Cloudflare's documentation says it adds another rua entry to an existing record. RFC 9989 allows several comma-separated report URIs, so reports keep going to your current destination as well as to Cloudflare. Check that any automation managing the record keeps both addresses after enablement.

Do I need quotes around the DMARC value in Cloudflare?

Not in the dashboard. Cloudflare adds double quotes automatically when you save new TXT content without them. In the API and Terraform, wrapping the value in escaped quotes matches the documented format. Avoid quote marks inside the value, which create a malformed record that receivers may not parse.

15

Final thoughts

Adding a Cloudflare DMARC record takes a minute in the dashboard and a few lines in the API or Terraform. The problems that cost time are operational: an inactive or duplicate zone, a second record from a script, a doubled name, a Cloudflare rua address that automation removes, or an SPF record added by Email Routing. Check delegation, read the record back, keep one source of truth per zone, and let aggregate reports decide when each client moves to the next policy level.

Related articles

Related tools

Ready to Implement?

Get authenticated mail moving in minutes: start free, book a guided demo, or talk to the team about your stack.