# Get started with Domains & certificates

Add a domain, prove it with one CNAME record, watch its certificate being issued, and delete it again, in about ten minutes.

Replace _apps.example.com_ with a name under a domain you own and can add DNS records to.

## Prerequisites

- Permission for `domains:CreateDomain`, `domains:VerifyDomain`, `domains:GetDomain` and
  `domains:DeleteDomain`; in the console also `domains:ListDomains`.
- For the CLI steps, the dcloud CLI, signed in. For the API steps, an access key.

## Step 1: Add the domain

**Console**
1. Open **Domains**, then choose **Add domain**.
2. For **Domain**, enter apps.example.com.
3. Select **Also every name one level under it**.
4. Choose **Add**.

The domain's page opens and shows the record to create, under **Proof**.

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

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

The answer's `proofRecord` names the record, for example
`_acme-challenge.apps.example.com CNAME _acme-challenge.3f9c….domains.apps.…`.

## Step 2: Create the CNAME

At the provider that answers DNS for your domain, create the `CNAME` record exactly as
`proofRecord` shows it. If the domain is in one of your hosted zones and the zone's delegation is
verified, there is nothing to create: the domain is verified as soon as you add it.

## Step 3: Verify

The platform looks for the record every five minutes. To look now:

**Console**
1. On the domain's page, choose **Verify now**.

**CLI**
```sh
dcloud domains domains verify apps.example.com
```

**API**
```http
POST /domains/api/domains/apps.example.com/verify
```

Once the record is found, **Proof** shows **Verified** and **Certificate** shows **Issuing**; a
few minutes later it shows **Active** with the expiry date.

## Clean up

**Console**
1. On the domain's page, choose the **⋯** menu, then **Delete domain**.
2. Enter the domain's name and choose **Delete**.

**CLI**
```sh
dcloud domains domains delete apps.example.com
```

**API**
```http
DELETE /domains/api/domains/apps.example.com
```

Then remove the `CNAME` record at your DNS provider.

## Next steps

- [Use a domain on an endpoint](use-a-domain-on-an-endpoint.md)
- [How proof and certificates work](how-proof-and-certificates-work.md)
