# Hosting

This page says what `durable-sdk apps create` makes and what every
deploy after it does, so you know what stands behind
`<app>.durablesdk.com`. The commands it names are `durable-sdk apps
create|list|rm|restore|set`, `durable-sdk deploy` and `durable-sdk
rollback`.

## One app, what it gets

`durable-sdk apps create <slug> [--region <word>]` runs one keyed run,
`app.create`, whose steps each have an undo. When it finishes, the app
has:

| Piece                    | What                                                                                                                                                                                                                             |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| a project                | its own build and function project in the app's [region](https://durablesdk.com/docs/hosting/regions.md); never shared with another app                                                                                                                   |
| a database               | its own Postgres in the same region, the `main` branch for production and one copy-on-write `preview` branch every preview deployment shares; sized by the tier ([Usage and limits](https://durablesdk.com/docs/hosting/usage-and-limits.md))             |
| the platform's variables | `DATABASE_URL`, `DATABASE_URL_UNPOOLED`, `CRON_SECRET`, `ADMIN_TOKEN`, `ADMIN_READ_TOKEN`, `CONSOLE_SESSION_PUBLIC_KEYS`, `DURABLE_*` ([Environment variables](https://durablesdk.com/docs/reference/environment-variables.md)); their names are reserved |
| a hostname               | `<slug>.durablesdk.com`, with TLS, answering the moment the first build is promoted                                                                                                                                              |
| the first deployment     | the template, built, promoted and read once at `/health`                                                                                                                                                                         |
| a console                | the dashboard's Console tab, reading the app's own operator API through the platform ([Console](https://durablesdk.com/docs/operate/console.md))                                                                                                          |

A failed step undoes what came before it (the project deleted, the
branch deleted, the database deleted, the slug freed) and the app shows
`failed` with the sentence; nothing is left half made and nothing waits
on a person. `durable-sdk apps list` shows status, hostname and the
current deployment.

## The hostnames

Every hosted hostname is a product hostname; no provider's hostname is
ever shown or answered.

| Environment | Hostname                             | Made at                                          |
| ----------- | ------------------------------------ | ------------------------------------------------ |
| production  | `<slug>.durablesdk.com`              | `apps create`                                    |
| a build     | `<slug>-<short id>.durablesdk.com`   | each production build, before its check          |
| preview     | `<slug>-git-<branch>.durablesdk.com` | `deploy --branch <name>`                         |
| staging     | `<slug>-staging.durablesdk.com`      | coming on Pro (DS-035)                           |
| custom      | your own, on Pro and up              | `domains add` ([Domains](https://durablesdk.com/docs/hosting/domains.md)) |

The slug is global across every account because the hostname is: 3 to 40
characters of `a-z`, `0-9` and `-`, a letter first, no `--`, no trailing
`-`, never containing `-git-` or ending in `-staging`
(`plane.app.slug_reserved_shape`), and never a reserved word (`www`,
`api`, `app`, `apps`, `admin`, `console`, `dashboard`, `docs`, `status`,
`mcp`, `auth`, `login`, `signup`, `cli`, `blog`, `mail`, `smtp`, `cdn`,
`static`, `assets`, `help`, `support`, `billing`, `platform`, `plane`,
`durable`, `durablesdk`, `internal`, `preview`, `staging`, `prod`,
`production`, `dev`, `test`, `ftp`, `ns1`, `ns2`, `accounts`, `clkmail`,
`clk`, `email`, `sales`, `security`, `legal`, `abuse`, and the two
providers' names). A branch is slugged to the same grammar and cut to 63
characters with a short hash when long.

## The build

A deploy uploads your tree ([Deploy](https://durablesdk.com/docs/hosting/deploy.md)) and the
platform builds it in the app's project under the project's variables.
The template's build script is:

```json
{ "build": "durable-sdk migrate --baseline=if-missing && tsc --noEmit" }
```

So the engine's migrations run inside the build against
`DATABASE_URL_UNPOOLED` of the target (production's `main` branch, a
preview's `preview` branch) and the owner credential never leaves the
project: your laptop never holds it and the platform never prints it.
The build's lines are yours to read (`durable-sdk deployments events
<id>`), redacted and masked at read.

## A production deployment: staged, checked, promoted

1. **Staged.** A ready production build is aliased to
   `<slug>-<short id>.durablesdk.com`. Production still points at the
   previous deployment.
2. **Checked.** The platform runs the same check `durable-sdk platform
check` runs: `/health`, the operator API's version, the ledger walk
   (`verify`), the time contract (`limits`) and the instance row. The
   rows land on the deployment (`check.rows`). A red check is `failed`
   with `plane.deploy.check_failed`; the build stays on its alias for you
   to read and is never promoted.
3. **Promoted.** Under the app's rule `auto` (the default) a green check
   moves production to the build. Under `manual` the deployment waits
   `ready` until `durable-sdk deployments promote <id>`. Set the rule with
   `durable-sdk apps set --promotion auto|manual` (`manual` on Pro and
   up).

A preview deployment is aliased to its hostname and ends `ready`; it is
never checked and never promoted.

## Rollback

```bash
durable-sdk rollback <deployment id>
```

Production points back at that deployment at once and the row reads
`rolled_back`. The schema is not walked down: a rolled-back build whose
schema requirement is below the current version is refused
`plane.deploy.down_pending` until the ordered down lands (DS-008). The
remedy until then is a forward deploy.

## Delete and restore

`durable-sdk apps rm <slug> --yes` (scope `admin`) stops the app within
the minute: its hostnames are removed and its project paused. The
database stays, the read string stands, and the slug is held for
`delete_hold_days` (7 on Free, 30 on Pro and Enterprise; a held app
counts toward `apps`). Inside the hold `durable-sdk apps restore <slug>`
brings it back whole; after the hold the project, the database and every
credential are purged and the slug is free. A slug inside another
account's hold is `plane.app.held`; a restore after the hold is
`plane.app.not_held`.

## What you never see

- The providers' names, hostnames, ids and error codes: every sentence
  the platform answers is its own, with a code, a remedy and a link
  ([Errors](https://durablesdk.com/docs/reference/api/errors.md)). The one provider hostname a
  tenant sees is the database host inside the read string, named on
  [the security page](https://durablesdk.com/security) with the subprocessors.
- The owner credential of your database: sealed on the platform, used
  by the build, the read string's minting and the instance rename, never
  printed.
- A secret you set: written to the project as a sensitive variable
  through a sealed value in flight and never read back
  ([Secrets](https://durablesdk.com/docs/hosting/secrets.md)).
- A bypass token, a provider dashboard, a provider seat: none exist for
  a tenant. A request to a provider-generated hostname of your project
  is answered 404 by your own app (`DURABLE_HOSTNAMES`).

## What runs the platform

The compute and the database are a hosting provider's and a managed
Postgres provider's under the product's contracts; the security page
names them once as subprocessors. The platform itself is a Durable app:
every change to your account is a keyed, ledgered run, and a run of
yours that a compensation could not finish is listed by `durable-sdk
runs limbo` and redriven by `durable-sdk runs redrive <runId>`.

---

Prompt for an agent:

```text
Read https://durablesdk.com/docs/hosting.md, then apply what it says to this app; run durable-sdk doctor --host before and after; a refused line is a refusal id: durable-sdk explain <id>
```
