# Preview URLs

Every deploy addressable — immutable build URLs you can say out loud, and per-branch aliases.

Releases are immutable and content-addressed, so every deploy has an
address. Three URL classes, all under the platform zone:

| URL | Points at | Changes when |
| --- | --- | --- |
| `my-site.pilvia.app` | the active release | you deploy to production |
| `canyon-jam-telescope-creek--my-site.pilvia.app` | that one build, for as long as it is retained | never |
| `draft-navbar--my-site.pilvia.app` | the branch's latest deploy | you deploy that branch |

A production deploy prints its own address and the build's; a branch
deploy prints the build's and the branch's:

```
deployed https://my-site.pilvia.app version 20260908T141530221
  build   https://gold-rapid-light-bridge--my-site.pilvia.app
```

## Build names you can say out loud

A build's name is a **humanhash** of its release: four words carrying the
same 32 bits as a short hex prefix, but they survive being said in a
meeting, pasted in a chat, or remembered overnight. The words come from the
same 256-word list [humanhash.dev](https://humanhash.dev) uses, so that
service explains any of our build names. When the four words would not fit
a hostname beside a long app name, or another retained build of the same
app already has them, the name is the release's hex prefix instead
(`e3b0c442--my-site.pilvia.app`) — the same thing, less memorable.

The same name works everywhere the release does:

```sh
pilvia app rollback my-site --to canyon-jam-telescope-creek
```

Build URLs are unlisted, not secret — access is decided by the release's
own manifest. **A preview is never a route around `auth: required`**: a
draft of a locked app is locked.

## Branch deploys

```sh
pilvia app deploy --branch draft-navbar   # or plain --branch: the git branch you are on
```

creates the release, its build URL, and moves the branch alias — and does
not touch production:

```
deployed version 20260908T141530221 as a preview — production unchanged
  build   https://silent-pelican-indigo-puddle--my-site.pilvia.app
  branch  https://draft-navbar--my-site.pilvia.app
```

Promotion to production is a deploy without `--branch`, or
`pilvia app rollback --to <build>` naming the draft's build. Branch names
are slugified to be DNS-safe (`feature/New-Navbar` → `feature-new-navbar`;
two branches that slug alike share the alias, last deploy wins). The `--`
separator is reserved, so app names cannot contain it, and app names are
capped at 30 characters so a build name fits beside them.

## Removing a branch preview

A branch alias stays until you remove it (`PILVIA_APP_SERVER` is the
control plane, `https://deploy.pilvia.dev` on the hosted platform, and
`PILVIA_DEPLOY_TOKEN` is your token):

```sh
curl -X DELETE "$PILVIA_APP_SERVER/v1/apps/my-site/branches/draft-navbar" \
  -H "Authorization: Bearer $PILVIA_DEPLOY_TOKEN"
```

```json
{ "name": "my-site", "branch": "draft-navbar", "version": "20260908T141530221" }
```

`draft-navbar--my-site.pilvia.app` answers 404 within about ten seconds.
Production does not change. The release the branch pointed at keeps its
build URL until retention retires it, and since it is no longer a branch
head, that can happen at once. Name the branch by its slug, as its URL
shows it (`feature-new-navbar` for `feature/New-Navbar`). Deploying the
branch again brings the alias back.

Removing needs a [token](/hosting/tokens.md) that covers the app and is not
pinned to a target. A branch the app does not have answers 404, and
`GET /v1/apps/my-site/aliases` lists the ones it has.

## The fine print

- Every preview hostname carries `X-Robots-Tag: noindex, nofollow`
  — a half-finished draft in a search index is a support ticket nobody
  wants. So does the production platform name, unless the app declares it;
  see [Request IDs and headers](/reference/headers.md#platform-names-are-unlisted).
- **Retention is finite**: the active release, every branch head, and the
  last 20 builds are kept; older releases are retired after each deploy and
  each branch removal, and their build URLs stop serving with a 404 that says
  so. "Immutable URLs forever" and a finite disk cannot both win, so the
  policy is written down instead of discovered.
- A preview is loaded the first time it is visited — the first request to a
  build with server code pays the compile, the way a fresh replica does.
- Branch deploys share the app's [KV data](/hosting/kv.md): a form test on a
  preview writes real data. There are no per-environment stores, so this
  is a documented footgun, not a surprise.
- Previews are served under the platform zone's wildcard certificate. Where
  the platform has none, they refuse to serve rather than issue a
  certificate per build; production hostnames are unaffected.

## Zero-config create

A deploy with no app name anywhere — no `name` in `pilvia.app.json`, no
`--name` — asks the platform for one. It mints a readable name
(`crimson-paper-7f2`: two words from the same list and a short tail),
reserves it, creates the app on the first commit, prints the URL, and
writes the name back into your `pilvia.app.json`. New creates, old updates,
nobody remembers anything.

Creating an app takes a [token](/hosting/tokens.md) that may create apps
(`--create`).
