# Add and verify a domain

Add a domain, with or without every name one level under it, and prove it is yours with a hosted zone or one CNAME record.

Replace _apps.example.com_ with your domain. The name is trimmed, lowercased and stored without a
trailing dot or `*.`, and cannot be changed later.

## Prerequisites

- Permission for `domains:CreateDomain` and `domains:VerifyDomain`. In the console, also
  `domains:ListDomains` to open **Domains** and `domains:GetDomain` to open the domain.
- Room in the **Domains** quota (see [Quotas](quotas.md)).
- Either a hosted zone of your organization that contains the domain and whose delegation is
  verified (see [Delegate a domain](/docs/dns/guide/delegate-a-domain)), or access to the DNS of
  the domain wherever it is hosted.

## Add the domain

Domains are free.

**Console**
1. Open **Domains**, then choose **Add domain**.
2. For **Domain**, enter apps.example.com.
3. (Optional) Select **Also every name one level under it** if the certificate should also cover
   `*.apps.example.com`, so each endpoint can have its own name under the domain.
4. Choose **Add**.

**CLI**
```sh
dcloud domains domains create --name apps.example.com --wildcard
```

**API**
```http
POST /domains/api/domains
{ "name": "apps.example.com", "wildcard": true }
```

**Terraform**
```hcl
resource "dcloud_domain" "apps" {
  name     = "apps.example.com"
  wildcard = true
}
```

A name of the platform itself is refused with `400` "… is the platform's own name"; a name your
organization already has with `409` "… is already a domain of this organization".

## Prove it

- **In a delegated hosted zone of yours**: nothing to do. The domain is verified when you add it,
  and `proofRecord` is `null`.
- **Anywhere else**: create the record the domain shows as `proofRecord` (in the console, under
  **Proof**), a `CNAME` from `_acme-challenge.<domain>` to a target that belongs to this domain
  alone. Keep it: every renewal of the certificate is answered through it. In Terraform,
  `proof_record_name` and `proof_record_value` hold it.

The platform looks for the proof every five minutes for 72 hours after you add the domain, then
once a day. To look now, choose **Verify now** on the domain's page, or run
`dcloud domains domains verify`. While it is not found, the domain shows **Waiting for proof** and
what was found instead; after 72 hours, **Not proven**.

## Result

The domain shows **Verified**, then its certificate **Issuing** and, within minutes, **Active**
with its expiry date. From now on no other organization can verify this name, a name under it or a
name above it.

## Related

- [Use a domain on an endpoint](use-a-domain-on-an-endpoint.md)
- [Troubleshooting](troubleshooting.md)
