# Add your domain

Prove you control a domain, publish its mail records, and turn on sending.

Adding a domain is the first thing to do with a new account since everything else is built on
top of it.

By the end of this article you will have published five required DNS records: one to prove
ownership, one to receive mail, and three to send it. You also may have to add a DMARC record if your
domain does not already have one.

Adding a domain happens in two milestones:

1. **Domain Verification.** You prove you control the domain. The domain now exists on the
  platform, and mailboxes and routes can be created on it.
2. **Sending & Receiving.** You set up how your domain should process email messages. Receiving
  starts working as soon as your MX points at OpenEmail. Sending starts working once the bounce
  and DKIM records are live.

There are three modes you can use to complete this step: the app, the CLI, and the API.
The app is typically the simplest place to start since it performs the entire DNS check loop for you.
The CLI and the API are the same loop performed by hand. They
are better choices for onboarding domains from a script or your own product.

API paths are relative to `https://api.open.email/api/v1`, and every request
carries an account credential. See
[Authentication](/docs/guides/authentication).

## Using the app

Sign in at [app.open.email](https://app.open.email) and go to **Add domain**.
Enter the domain and the app takes it from there.

1. **Prove domain ownership.** Add the TXT record to prove you have access to your domain's DNS records.
   Add the verification record and token that the app displays to your DNS provider. Stay on this screen
   until you see the record verified. The app re-checks every 15 seconds and registers the
   domain the moment the record answers, so there is nothing to press; **Verify
   now** forces a check if you would rather not wait. This record is typically confirmed within a few minutes.
2. **Set up sending and receiving.** Once you prove you control the domain, you will see
   the rest of the DNS records to complete setup. Add each one and wait for it to resolve.
   Nothing is lost if you leave the page: the domain is already registered, and the app
   picks up wherever your DNS has got to when you come back.
   - The MX record tells incoming messages where to go.
   - The CNAME bounce record gives your domain a return address, which is where
     failed deliveries come back to and how receivers confirm we may send for
     you. It does the job an SPF record would, which is why there is no SPF
     record here to add.
   - The 2 DKIM records sign outgoing messages, so receivers can tell real mail
     from your domain apart from mail forging it.
   - [optional] The DMARC record tells receivers what to do with mail that fails
     those checks, and can send the resulting reports to us so you can see who
     is sending as your domain.

Once the required DNS records are confirmed, your domain is set up.

Note that each record indicates what it enables the domain to do right now rather than only
which records are green. When a DNS record is published incorrectly, it says which
record and what is wrong with it. For example, a bounce CNAME pointing somewhere else reads
differently from one that was never added. If DNS cannot be reached at all, the
check pauses and says so rather than marking your records failed.

## Using the CLI or API

The steps below are the same loop the app runs for you, performed by hand. It is
one command run repeatedly: each run tells you what to publish next, and
publishing it and running again is how the domain advances.

### 1. Generate the ownership record

```bash
openemail domains create example.com
```

This is the claim command, and every step below is the same command run again.
Technically you are claiming the domain from this very first run — but the claim
does not take until ownership is verified, and nothing proves the domain is
yours yet. So this run claims nothing. It refuses, and prints the record that
will prove it, token already filled in:

```
! example.com is not verified yet.
Publish this DNS record, then run the same command again:
```

The API call underneath:

[`POST /domains`](/docs/api/domains/post_DomainCreate)

```bash
curl -X POST "$API/domains" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain": "example.com"}'
```

Before the TXT is live this answers `400 domain_not_verified` and returns the
record to publish in the response body under `record`, so a first call is how
you learn what to publish over the API too. Nothing is created until control is
proven, so an unverified claim never holds a name in the global namespace.

**Reading the token without a failed call.** You do not need this to follow the
loop, but the token can also be read straight from your account, which is what to
do when you provision domains from a template rather than from the response:

[`GET /accounts/{accountId}`](/docs/api/accounts/get_AccountGet)

```bash
curl "$API/accounts/$ACCOUNT_ID" \
  -H "Authorization: Bearer $TOKEN"
```

The `verificationToken` in the response is your proof of control. It belongs to
your **account**, not to a domain: it is stable for the life of the account, and
you publish the same value on every domain you bring. It goes into a
provisioning template once and is never revisited.

The token is a claim capability, not a secret. Someone who learns it can only
use it by publishing it in DNS on a domain, and publishing it on a domain they
control merely lets *your* account claim *that* domain. It is never an
authentication credential and is never accepted as one.

### 2. Publish the ownership record

| Type | Name | Value |
| --- | --- | --- |
| TXT | `_openemail.example.com` | `openemail-verification=<your token>` |

Copy the record from the run you just made rather than transcribing this table.
It comes back with your account's token already in it.

Other vendors' verification records at that name are fine. The check looks for
its own value among whatever is published, and the tag is namespaced so a domain
carrying a dozen of them stays unambiguous.

### 3. Claim the domain & generate the mail records

Run the same command once the TXT resolves. This time the claim takes, and it
lists the records still to publish:

```bash
openemail domains create example.com
```

```
✓ Domain example.com is verified
Still to publish (re-run this command afterwards to activate sending):
```

This is the only endpoint in the flow, and calling it again is not an error: it
re-resolves DNS and advances the domain as far as your records now allow. That
is what makes the publish-then-call loop work without a second verb.

A `200` means the domain exists on the platform: `receiving` is `true`,
`sending` is `false`, and `records` carries the mail records still to publish,
each with its liveness. Anything else is a refusal that names what to fix:

| Status | Error | What it means |
| --- | --- | --- |
| `400` | `domain_not_verified` | The TXT is not visible yet. The record to publish comes back in the response body under `record`. |
| `409` | `domain_claimed_elsewhere` | You proved control, but another account holds the domain. An operator has to transfer it. |
| `409` | `domain_unavailable` | Every other conflict, deliberately indistinguishable, so this endpoint cannot be used to discover which domains other tenants hold. |
| `503` | `verification_unavailable` | DNS could not be queried at all, so control could not be proven either way. Nothing was created; retry. |

### 4. Publish the mail records

| Type | Name | Value | |
| --- | --- | --- | --- |
| MX | `example.com` | `smtp.open.email` (priority 10) | Required |
| CNAME | `oe-bounce.example.com` | `oe-bounce.open.email` | Required |
| CNAME | `oe1._domainkey.example.com` | `oe1.dkim.open.email` | Required |
| CNAME | `oe2._domainkey.example.com` | `oe2.dkim.open.email` | Required |
| TXT | `_dmarc.example.com` | `v=DMARC1; p=none; rua=mailto:example.com@dmarc.open.email` | Recommended |

The exact records for your domain, already filled in, are always in the
`records` array of the call you just made. Copy them from there rather than
transcribing the table.

**MX, for receiving.** Mail reaches us only if your MX points at us, and setting
that MX is itself proof of control, so receiving has no gate of its own: MX
liveness is *reported*, never enforced. Mail starts arriving the moment the
record propagates.

**The bounce CNAME, for SPF alignment.** There is no SPF record to add at your
apex. The relay rewrites the envelope sender to a return path inside
`oe-bounce.example.com`, so receivers evaluate SPF against that name instead of
your apex. That keeps SPF aligned under DMARC's relaxed default, alongside DKIM,
and it spends none of your apex's ten-lookup budget (RFC 7208 §4.6.4).

On Cloudflare, set this record to **DNS only**. The proxy toggle defaults on for
an ordinary-looking name, and a proxied CNAME is invisible to resolvers
(synthesized A/AAAA records replace it), so the check then reads exactly like a
missing record.

**The two DKIM CNAMEs, for signing.** You publish them once. They delegate to keys
the platform holds and rotates for you, so no key material lives in your zone and
there is nothing to re-publish when a key rotates. Both are required: DKIM is
green only when both selectors resolve.

**DMARC, if you do not already have one.** DMARC is what makes SPF and
DKIM enforceable rather than advisory, so a domain that sends mail wants a
record even though the check reports this one as recommended rather than
required. `p=none` monitors without affecting delivery, and the policy stays
yours to choose. If your domain already publishes a DMARC record, keep it.
Nothing here replaces it. Keep only one, though: receivers apply DMARC only
when a domain publishes exactly one record, so with two, neither is in effect.

Pointing `rua` at us is **recommended, but not required**. It is what lets us
ingest your aggregate reports and answer whether the domain is safe to enforce,
readable at
[`GET /domains/{domain}/dmarc`](/docs/api/domains/get_DomainDmarc). Send them
somewhere else, or nowhere, and everything else still works. If you do use ours,
keep the address exactly as issued rather than substituting the boilerplate from
a generic DMARC guide: the local part is your own domain name, which is what
lets an incoming report be attributed from its envelope rather than from its
attacker-supplied XML body.

### 5. Turn on sending and receiving

Run the same claim again once the bounce CNAME and both DKIM CNAMEs are live.
The command is idempotent, and re-running it is how the domain advances:

```bash
openemail domains create example.com
```

Or over the API:

```bash
curl -X POST "$API/domains" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"domain": "example.com"}'
```

When all three resolve, `sending` flips to `true` and outbound submission is
accepted for the domain. Publishing everything up front works too, and one call can
verify and activate in a single step.

Receiving needs no step of its own. It switched on the moment your MX resolved,
since pointing MX at us is itself the proof, so by the time sending activates the
domain is already taking mail.

Activation is one-directional. A record disappearing, or a resolver blip during
a later check, never turns sending back off: your mail must not stop because DNS
was briefly unreadable. You can always revoke your own sending with
[`PATCH /domains/{domain}`](/docs/api/domains/patch_DomainUpdate) and
`{"canSend": false}`, but the reverse is not self-service. An account cannot
grant itself sending (`403 sending_not_writable`), which is what makes the DNS
proof mean something.

## Optional DNS: JMAP and DAV

Two further record sets are available, both off by default and both enabled per
domain. Neither is needed for mail to work; they exist so that clients can
configure themselves.

**JMAP** is a modern JSON-over-HTTP protocol for email, the alternative a
JMAP-native client speaks instead of IMAP.

**DAV** covers CalDAV and CardDAV, the two standard protocols for syncing
calendars and contacts. They are what a client uses for the rest of what an
email account carries, alongside the mail itself.

Both define an autodiscovery convention: publish an SRV record at your domain
and a client can find the server from an email address alone, so nobody has to
type in hostnames and port numbers.

Pass them when you claim the domain (`openemail domains create example.com
--jmap --dav`), or turn them on later with `openemail domains update
example.com --jmap` or `PATCH /domains/{domain}`:

- `jmap: true` offers the `_jmap._tcp.example.com` SRV record, so a JMAP client
  can configure itself from an address alone (RFC 8620 §2.2).
- `dav: true` offers the `_caldavs._tcp` and `_carddavs._tcp` SRV records and
  their `path=/dav/` TXT hints, for CalDAV and CardDAV clients (RFC 6764).

They are opt-in because a domain counts as fully configured only when every
record it offers is live. Advertising records that most customers' clients never
look up would leave a correctly configured mail domain reporting incomplete DNS
forever.

## After you add your domain

### Check status any time

```bash
openemail domains dns example.com
```

[`POST /domains/{domain}/dns/check`](/docs/api/domains/post_DomainDnsCheck)

```bash
curl -X POST "$API/domains/example.com/dns/check" \
  -H "Authorization: Bearer $TOKEN"
```

The same records and the same liveness, without advancing the domain's state.
This is what to poll while records propagate, and what a status dashboard
renders. The response carries a per-kind verdict in `status` (`mx`, `spf`,
`dkim`, `dmarc`) plus the full `records` array, where each entry has `ok` and the
`found` values actually seen at that name. `found` is usually the fastest way to
spot a typo: it shows what *is* published, not merely that it did not match.

A verdict is cached for 30 seconds so that polling through propagation cannot
hammer the resolver. `?force=true`, or `--force` on the CLI, re-queries
immediately, and is rate limited per account for that reason.

If DNS cannot be queried at all the answer is still `200`, with
`resolverUnavailable: true` and `ok` **absent** rather than `false`, since
unknown is not the same as broken, and nothing is stored. An outage on our side must never
look like a misconfiguration on yours.

### Create mailboxes on it

The domain is now real to the platform, so addresses on it can be claimed:

```bash
openemail mailboxes create --address you@example.com --json
```

```bash
curl -X POST "$API/identities" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"primaryAddress": "you@example.com"}'
```

The mailbox, its address route, and its label are claimed atomically, so it
starts receiving immediately. See [Mailboxes](/docs/guides/mailboxes) for the
rest of that surface, and [Sending](/docs/guides/sending) for outbound.

### In the TypeScript SDK

Each call on this page is a method of the [TypeScript SDK](/docs/sdks/typescript):

- [`domains.create`](/docs/sdks/typescript/domains/create) is `POST /domains`,
  steps 1, 3 and 5;
- [`accounts.get`](/docs/sdks/typescript/accounts/get) is `GET /accounts/{accountId}`;
- [`dmarc.getSummary`](/docs/sdks/typescript/dmarc/get-summary) is
  `GET /domains/{domain}/dmarc`;
- [`domains.update`](/docs/sdks/typescript/domains/update) is `PATCH /domains/{domain}`;
- [`domains.checkDns`](/docs/sdks/typescript/domains/check-dns) is
  `POST /domains/{domain}/dns/check`, its `force` option `?force=true`;
- [`identities.create`](/docs/sdks/typescript/identities/create) is `POST /identities`.

## Troubleshooting

| Symptom | Likely cause |
| --- | --- |
| `domain_not_verified` immediately after publishing | The record has not reached the nameservers being queried. Verification reads your authoritative nameservers directly where it can, so this is usually seconds rather than a cache TTL. Retry. |
| `domain_not_verified` long after publishing | The record may have landed at the wrong name. Some DNS providers append your domain to a name that is already fully qualified, turning `_openemail.example.com` into `_openemail.example.com.example.com`. Enter the host part on its own (`_openemail`), or end the name with a trailing dot if your provider accepts one. Shopify is one that appends; the `found` values in a check response show where the record actually is. The same trap applies to `oe-bounce`, both `_domainkey` names, and `_dmarc`. |
| A TXT value looks correct but never matches | Providers disagree about quoting. Some expect the value wrapped in double quotes to mark it as a single string; others store exactly what you type, so the quotes become part of the value and `"openemail-verification=abc"` never matches `openemail-verification=abc`. Compare against `found` to see which you got, then add or drop the quotes to suit the provider. Affects the `_openemail` and `_dmarc` records. |
| An MX or CNAME target reads as missing | The hostname in the record's *value* may need a trailing dot. Every domain name really ends in one — `smtp.open.email.` is the absolute form — and a provider that expects it treats a name without one as relative, appending your domain to give `smtp.open.email.example.com`. This is the same trap as the row above, on the value side rather than the name side. Ending every hostname you paste with a dot is the safest form wherever the provider accepts it. |
| `spf` never turns green on Cloudflare | The `oe-bounce` CNAME is proxied. Switch it to DNS only. |
| `dkim` stays `false` with one record live | Both `oe1` and `oe2` are required; the kind is green only when both resolve. |
| `dmarc` is `false` though a DMARC record is published | The domain publishes two or more DMARC records, and receivers then apply none (`found` lists each): delete all but one, or merge them into one. Or its one record sets no policy, with neither a `p=` tag nor a `rua` address. |
| `unknown_domain` when creating a mailbox or route | The domain has no row yet: step 3 has not succeeded for it. |
| `sending` still `false` with every record live | Run `openemail domains create example.com` again. Sending activates on a check, not on a timer. |
| A record looks right but reads as missing | Compare it against `found` in the check response. It reports the value actually published at that name, which is usually enough to tell which of the cases above you have hit. |
