txt
Add a TXT record to a domain's Cloudflare DNS zone, at the domain root or at a name you choose
- Command:
/go/txt - Category: DNS
- Required option:
<domain>and<value> - Output: Plain text, from the
cloudflarecommand - Last updated: 2026-11-20
On this page: Overview · Quick start · Syntax · Options · Output · Examples · Troubleshooting · Details · See also
Overview
TXT records hold text in DNS. Services use them to verify that you own a domain (Google, Microsoft, and others), to publish email policies, and to answer certificate challenges.
/go/txt is a shortcut for adding one. It does no DNS work itself. It passes your arguments to cloudflare with the record type set to txt, and that command makes the change through Cloudflare's API.
Quick start
# A TXT record for the domain itself
/go/txt example.com google-site-verification=abc123
# A TXT record at a chosen name
/go/txt example.com _acme-challenge Abc123Def456
Syntax
# Record for the domain itself (no name is passed)
/go/txt <domain> <value>
# Record at a chosen name
/go/txt <domain> <name> <value>
The number of arguments decides what they mean:
| Arguments | Meaning |
|---|---|
| 2 | <domain> and <value>. No name is passed, so cloudflare uses its default. |
| 3 | <domain>, <name>, and <value>. |
The two forms are equivalent to:
/go/cloudflare --domain <domain> --type txt --value <value>
/go/cloudflare --domain <domain> --type txt --name <name> --value <value>
Options
| Argument | Required | Notes |
|---|---|---|
<domain> |
Yes | The domain to update. It must already be in Cloudflare. |
<name> |
No | The record name, for example _acme-challenge. Use a name relative to the domain. |
<value> |
Yes | The text of the record. |
Arguments after the third are ignored.
[!IMPORTANT] The script passes
<value>on without quotes, so a value that contains spaces is split into several words, even if you quote it when you run the command. A value without spaces, such as a verification token, works as expected. For SPF, DKIM, and DMARC records, which contain spaces, usespf,dkim, anddmarc.
Output
The command prints whatever cloudflare prints. It adds no output of its own. The exit status is the one returned by cloudflare.
Every run is logged to /var/log/go/txt.log with a timestamp and the arguments used.
Examples
# Domain verification token on the domain itself
/go/txt example.com google-site-verification=abc123
# Microsoft 365 verification record
/go/txt example.com MS=ms12345678
# A challenge record at _acme-challenge.example.com
/go/txt example.com _acme-challenge Abc123Def456
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Only the first part of the value was saved | The value contains spaces. | See the note under Options. Use the matching command (spf, dkim, dmarc), or add the record in Cloudflare. |
| The record has the wrong name or value | With two arguments, the second is the value. With three, the second is the name. | Check the number of arguments. |
| Error about a missing domain or value | An argument is missing. | Pass at least <domain> and <value>. |
| Domain not found in Cloudflare | The domain hasn't been added to your Cloudflare account. | Add it first with dns. |
| Authentication or API error | Cloudflare credentials aren't configured or have expired. | Check the setup described on the cloudflare page. |
| The service doesn't find the record | DNS changes haven't propagated yet. | Wait a few minutes, then check with dig TXT <name>.<domain>. |
Details
The script does two things:
- Appends a line to
/var/log/go/txt.log. - Runs
sudo /go/cloudflarewith--type txt, adding--nameonly when you gave three arguments.
Nothing is validated. Whether a record with the same name is replaced or added next to the old one is decided by cloudflare.
See also
| Command | Description |
|---|---|
cloudflare |
Manage DNS records using Cloudflare's API |
dns |
Add your domain to Cloudflare and edit the DNS zone |
cname |
Add a CNAME record to a domain through Cloudflare |
mx |
Add an MX record to a domain through Cloudflare |
spf |
Add or refresh the SPF TXT record via Cloudflare |
dkim |
Add a DKIM TXT record in Cloudflare (auto-generated or custom value) |
dmarc |
Add a DMARC TXT record in Cloudflare (auto-generated or custom value) |
google |
Add Google verification and Workspace DNS records via Cloudflare |