# Domains on staging and previews

> Give staging or a preview a name under your live domain, such as staging.example.com, one name at a time, and set its DNS records.

Source: https://docs.wpwaterfall.com/staging-domains

Custom domains belong to live. Staging and preview environments can use names under a domain that is connected to live. If live has `example.com`, staging can use `staging.example.com` or `dev.example.com`, and a preview can use `pr-12.example.com`.

## Before you start

Connect the domain to live first. Open your site, switch to **Live**, open **Domains**, and add the domain there. Once it shows **Active** or **Securing your site**, staging can use names under it.

If live has no connected domain, the Domains tab of staging says so and links to live.

## Add a name to staging or a preview

1. Open your site, switch to the staging or preview environment, then open **Domains**.
2. Choose **Add a subdomain of your live domain**.
3. Pick the live domain, then type the name in front of it, such as `staging`. The dialog shows the full name.
4. Choose **Add name**.
5. The dialog shows the DNS records to set, the same kinds as for live, at the new name. If the domain's DNS is on Cloudflare DNS, WP Waterfall writes them for you. See [Domains](https://docs.wpwaterfall.com/domains#what-do-i-add-at-my-dns-host).

The name shows in the list, with a tag beside it while it waits or after it fails. Remove it from its menu.

## Several names for one environment

Staging and previews take one name at a time, with no wildcard. To send several subdomains to one environment, add each one: `staging.example.com`, then `dev.example.com`, and so on. Each name gets its own certificate. The API refuses a wildcard on staging and previews with the code `wildcard_live_only`.

## Which environment answers

Each name goes to the one environment that holds it:

1. A name added on an environment goes to that environment. `pr-12.example.com` on a preview goes to that preview.
2. Live keeps its own names, such as `example.com` and `www.example.com`.

## Limits

- Up to 10 names per site on staging and previews together.
- Each name works on one environment at a time. To move a name, remove it, then add it on the other environment.
- No apex of a domain that is not on live, and no domain that is not under a live domain.
- The primary domain is a live setting. Staging and previews keep their temporary domain as primary.

If the API refuses a name, it says why in one sentence, with one of these codes: `live_not_launched`, `live_domain_required`, `not_under_live_domain`, `hostname_taken`, `staging_domain_limit`, `www_live_only`, `primary_live_only`, or `wildcard_live_only`.

## When the live domain goes

If you remove a domain from live, WP Waterfall removes the staging and preview names under it too, and the job log says which ones. A name that another live domain still covers stays. For example, `dev.shop.example.com` stays when `example.com` goes but `shop.example.com` remains on live.

Deleting a preview removes its names as well.

## With an AI assistant

The `add_domain` tool takes an `environment`, such as `staging` or a preview name, and follows the same rules. `get_domain_status` takes it too.
