> ## Documentation Index
> Fetch the complete documentation index at: https://docs.levelrail.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Preview domains

> Give every preview an automatic name under one wildcard certificate by setting a preview domain. Settings, CLI, dashboard and DNS-01 token needs. Experimental.

A preview domain is one subdomain you own, such as `preview.example.com`. When it is set, Levelrail writes one `*.preview.example.com` DNS record, issues one wildcard certificate for it, and gives each preview a host under it (for example `web-pr-12.preview.example.com`). While `previews.domain` is empty the feature is off and previews keep their current hosts.

> [!WARNING]
>
> Experimental. It is built and tested against fake DNS providers and a fake ACME issuer. It has not yet been proven with a real wildcard certificate and a real DNS provider. See [Feature status](https://docs.levelrail.com/feature-status.md).

## Settings

All keys are [runtime settings](https://docs.levelrail.com/runtime-settings.md) that apply live. The environment variable only seeds the default.

| Key | Default | Meaning |
| - | - | - |
| `previews.domain` | empty (off) | The preview subdomain. Must be a subdomain you own, not a public suffix. |
| `previews.domain_name_style` | `pr` | `pr` names a preview `app-pr-N`, `branch` uses the branch name, `readable` picks two stable words. Applies to new previews only. |
| `previews.domain_reserved_labels` | `www:api:mail:admin:dashboard:app:status` | Names a preview may never take. A hit gets a `-preview` suffix. |
| `previews.domain_collision_attempts` | `9` | Numbered suffixes tried when a name is taken (1 to 99). |
| `previews.domain_private_ip` | `warn` | `warn` shows a notice when the domain points at a private address, `block` refuses to set it up. |
| `previews.domain_wildcard_state_ttl` | `10m` | How long a confirmed wildcard record is trusted without a fresh provider answer (1m to 24h). |

## Set it up

CLI (writes need a root token):

```bash theme={"dark"}
levelrail-cli domains preview-domain status
levelrail-cli domains preview-domain set preview.example.com
levelrail-cli domains preview-domain set preview.example.com --confirm
levelrail-cli domains preview-domain check preview.example.com
levelrail-cli domains preview-domain clear --confirm
```

`set` is a dry run until you pass `--confirm`. A foreign wildcard record is replaced only with `--replace`. Add `--json` for machine output.

Dashboard: open Platform, Ingress and use the Preview domain card. It shows the connection check, a dry run and a safe enable step.

## DNS-01 token needs

A wildcard certificate needs the ACME DNS-01 challenge, so Levelrail must be able to write TXT and wildcard records in the zone. Connect a DNS provider first (Cloudflare, Route53 or Google Cloud DNS, see [Domains and ingress](https://docs.levelrail.com/domains-and-ingress.md#wildcard-domains-dns-01-providers)). For Cloudflare the token needs `Zone:DNS:Edit` and `Zone:Zone:Read` on the zone that contains the preview domain. The setup check does a safe DNS probe and names a missing scope.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.