# Publishing an App

An app becomes a working tool for other people by being **published**. Publishing takes a **saved version** and puts it in production, giving the app its own live URL. Until you publish, the app runs only in the AppBuilder's preview. Anyone with **Editor** or higher on the app can publish it.

Open the **Publish** panel from the AppBuilder header — *Publish a saved version to production. It is built, its database changes are applied, and it goes live once it answers at the app's URL.* It has two parts:

- **Production** — what is live now: the app's URL, the live version (*vN live*) and when it was published, or **Not published yet** before the first publish. A publish in progress (even one started in another tab) shows its steps here, and a failed one shows why while leaving whatever was already live untouched. Anyone who can edit the app can **Cancel** a publish while it is still building or deploying; once the new version has deployed and is only waiting to go live, publishing another version replaces it instead. If a deployment hasn't been confirmed yet, the panel says the version *may already be serving* rather than calling it live.
- **Versions** — every saved version, newest first, with its save time and note; the newest is marked **latest saved** and the one in production **Live**. Each has its own **Publish** button. Publishing is one step per version — *Publish vN to production* — so publishing an earlier saved version is also how you roll an app back. Only saved versions can be published: if you have unsaved changes the panel says so (*Publishing uses saved versions — Save to include your latest changes*), and an app with nothing saved yet offers **Save first version** in the panel, which, like **Save version**, waits while the builder is working on a request.

## What happens when you publish

Clicking **Publish** on a version starts a publish that builds that version on a fresh build machine. The panel lists its steps as they run, each with how long it took:

| Step | What happens |
|------|--------------|
| **Start build machine** | A build machine is started for this publish alone. |
| **Get vN source** | The saved version's source is fetched. |
| **Install packages** | The app's dependencies are installed from its own `package.json` and lockfile. |
| **Check database changes** | Its database migrations are compared with what the published app's database already has. |
| **Build** | The app is built for production. |
| **Update database** | New migrations are applied to the published app's [database](/insulin/custom-apps/running/#data-an-app-keeps-for-itself). |
| **Deploy** | The build is deployed. |
| **Go live** | The version is recorded as live only once the app's URL answers with it. |

While it runs, the header's **Publish** button says which version and step it has reached (*Publishing v4 · Build*), so you can close the panel and keep working. **Show build log** opens the app's own install and build output. A successful publish ends with *vN is live*, how long it took, and the app's URL.

If a step fails, the panel says *Publishing vN failed at* that step, explains what went wrong and what to do about it, and — for any step before **Go live** — confirms *Production is unchanged — still vM*. The build log opens on its own, and **Publish vN again** retries the same version once you have fixed the cause.

## Where a published app answers

What address a published app has depends on its [access setting](#who-can-open-a-published-app):

- A **Public** app answers at its **default domain**, a subdomain of `insulin.host`. Every app is given a random five-letter name when it is created — such as `qwert.insulin.host` — which an app admin can [rename](#the-apps-domain). It can also answer at a [custom domain](#the-apps-domain) you own.
- A **Console-only** app opens through the Fours console instead, under your own sign-in — see [Running a Saved App](/insulin/custom-apps/running/).

The address is shown in the Publish panel, on **Settings → Domain**, and in the runner window when the app can't be embedded.

## The app's domain

**Settings → Domain** lists *the domains this app answers on when it is public on the web*, in two rows. Only an app admin — the app's **Owner** or an **Admin** on it who is also an organization **ADMIN** or **EDITOR** — can change them; everyone else sees *Only an app admin can change these.*

**Default domain** is the app's own `insulin.host` address. Until a Public app has been published, the row says *Not answering yet — it starts at the next publish*; for a Console-only app it says *Not public — this app opens only from the console.* To choose a different name, click **Rename**, type the new subdomain — lowercase letters, numbers and hyphens, 3–63 characters — and click **Save**. The rename applies at once: for a Public app that is already live, *The old address redirects here for 30 days*; otherwise *The old address stops working.*

**Custom domain** serves the app at an address you own, such as `apps.acme.com`. Use a subdomain: a bare domain such as `acme.com` isn't supported.

1. Enter the domain and click **Add domain**.
2. **Add the DNS records** — add the two records the row shows at your DNS provider: a TXT record that proves you own the domain, and a CNAME that points it at Fours. Each name and value has its own **Copy** button. Names are shown without your domain's zone, since most DNS providers add it for you; if yours asks for the full name, the row shows that too. On Cloudflare, set the CNAME's proxy status to **DNS only** (grey cloud).
3. **Verify you own the domain** — Fours looks for the TXT record on its own and keeps checking; **Check now** checks straight away.
4. **Secure with HTTPS** — once ownership is verified, Fours issues the domain's certificate.

The row's status badge shows where the domain is:

| Status | Means |
|--------|-------|
| **Waiting for DNS** | The records have not been found yet. |
| **Issuing certificate** | Ownership is verified and the HTTPS certificate is being issued. |
| **Live** | The domain is connected. Keep both DNS records in place — removing them takes the app offline at this address. |
| **Not connected** | The CNAME record is no longer in place. Setup resumes once it is back. |
| **Removing** | The domain is being disconnected from the app. |
| **Unavailable** | The domain is already connected to another app. Remove it here and connect a different one, or ask the other app's owner to remove it first. |

Once the custom domain is **Live** and the app is published as **Public**, it becomes the app's main address — the Publish panel shows it first — and the default domain keeps working beside it. On a Console-only app, a connected domain opens the app through console sign-in, like the default domain. To disconnect a domain, open the row's **⋯** menu and choose **Remove domain**: *The domain stops serving this app. Adding it again later needs its DNS records verified again.*

## Secrets reach the app when you publish

Publishing is also what delivers the app's **secrets** — the owner's own credentials for the app — to the live app. Secrets are managed on the [Settings surface](/insulin/custom-apps/building/#studio-surfaces); the Publish panel's **Manage secrets in Settings** takes you there. The [preview](/insulin/custom-apps/building/#the-live-preview) receives them too, but the live app gets them only at a publish, so adding or changing a secret means re-publishing. Removing one also asks for it to be removed from the live app straight away: the Secrets section shows *Live removal is requested; its progress appears below.* and tracks it under **Live removal requests**, with **Retry removal** if it fails. Where that isn't available, it shows *The live app keeps it until you publish again.* Only the app's **Owner** or an **Admin** on it can add or remove a secret — and *Anyone who can edit and publish this app can read these values from its environment. Share it accordingly.*

The builder's assistant can ask for a secret change, but it cannot make one. If you are the app's **Owner** or an **Admin** on it, the request opens **Settings** at **Secrets** with either the add form ready for the secret it named — you enter the value yourself — or a confirmation to remove it: *The assistant requested this removal. Confirm to delete the stored value and request removal from the live app.* Nothing changes until you save the form or click **Remove secret**.

## Who can open a published app

**Settings → Access → Published access** decides who can open the app once it is published:

| Setting | Who can open the published app |
|---------|-------------------------------|
| **Console-only** | Only people signed in to the Fours console who have access to the app. A new app starts here. |
| **Public** | Anyone with the published URL. Sharing still decides who can edit the app. Apps created before this setting existed are Public until someone changes them. |

Only the app's **Owner** or an **Admin** on it can change the setting; everyone else sees it read-only. Switching a Console-only app to Public asks you to confirm in **Allow public access?**, because anyone with the URL could then open it without signing in. The change takes effect at the next publish — **Live access** shows what the published app uses now — so publish a saved version, then check the publish status to confirm the change is live.
