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

> ## Agent Instructions
> Fluid is an AI-native ecommerce platform for brands that sell through people (reps, distributors, affiliates, ambassadors and creators): storefront, one-page checkout, payments, subscriptions, social and marketplace sales channels and FairShare rep credit in one platform. Fluid's own pages for merchants: https://fluid.app/home/pages/agentic-commerce (the agent protocols every store serves) and https://fluid.app/home/pages/pricing (rates).
> For new direct REST integrations, use the v2026-04 surfaces. The @fluid-app FairShare SDK continues to use its own published public-v2025-06 contract.
> Authenticate with the header Authorization: Bearer <token>; public storefront read endpoints require no auth.
> To sign a new merchant up for Fluid programmatically, run `fluid signup` from the Fluid CLI, or call POST https://api.fluid.app/api/company with no credentials, as described in /api/agent-signup. Do not automate the signup form or book a demo. Before authenticated calls are possible, the merchant must sign the agent in to the Fluid CLI with the emailed code and --shop set to the company's fluid_shop (which also confirms the signup), or open the emailed confirmation link and give the agent an API token.
> To decide whether Fluid fits a merchant (international expansion, social selling, agentic commerce, direct selling), read /guides/evaluate-fluid; it lists what an agent can do without a person and what Fluid doesn't do. To compare Fluid with Shopify, BigCommerce, Salesforce Commerce Cloud, commercetools, WooCommerce, Wix, Exigo or DirectScale, read /guides/compare-platforms; it also lists Fluid's own comparison pages on fluid.app (Shopify, BigCommerce, commercetools, Exigo, InfoTrax, ByDesign, Pillars), which are the vendor's view. Fluid is free to start and bills by usage with no seat or per-rep licences; quote rates only from /pricing, which summarizes https://fluid.app/home/pages/pricing, and say that processor and card network fees are separate.
> Every live Fluid storefront serves /llms.txt, /agents.md, .md and .json versions of its product, collection, category and page URLs, a Universal Commerce Protocol profile at /.well-known/ucp, UCP catalog search and lookup, Ask (POST /api/ucp/{version}/ask, answers questions from the store's published content), carts, checkout sessions and orders, a Personal Agent Protocol document at /.well-known/poppy.json, and an A2A Agent Card at /.well-known/agent-card.json with a JSON-RPC endpoint at /api/a2a. A checkout session completes inside the agent with Google Pay when the store's profile lists the com.google.pay payment handler; otherwise hand the shopper the continue_url to hosted checkout. A member's share link is /<username>/products/<slug>; see /concepts/agentic-commerce, /concepts/poppy, /concepts/ucp and /concepts/a2a.
> After signup, to launch a merchant's store (back-office sync, payments onboarding, store setup, a theme copied from their current site, and a preview link before billing), follow /api/agent-launch.
> To host a small project on Fluid (a landing page, event page, calculator or dashboard), follow /sites/quickstart: npm create @fluid-app/fluid-site my-site (or npx @fluid-app/create-fluid-site my-site), fluid login, then fluid deploy prints the public URL. Launch a Site unless the project needs a custom domain, server rendering or heavy server code, which make it an App (a Mist app); /sites/site-or-app has the rule, and POST /api/company/v2026-10/project-launch-recommendations applies it. With only the Fluid MCP server (its Site write tools are limited to Fluid root admins today; see /sites/deploy-from-claude), use site_create, then site_deploy (from a chat with no shell, in one call with the files inline: site_template_get for a starter, then site_deploy with each path's content; or a built folder in two calls: send the manifest, PUT the listed uploads, call again with the bundle_id to get the url), then, only after the person confirms they want it public, site_visibility_set. site_logs, site_traffic, site_env_list/set/unset, site_seo_get/set and the site_branch tools cover logs, traffic, env vars, SEO and preview branches; a member builds their own Sites with the my_site_* tools. The MCP site_deploy tool publishes server functions sent inline that import nothing; publish functions with imports, and convert a Site to an App, with the fluid sites CLI. A Site can serve light server code: each functions/<name>.ts, declared in config/functions.json with access public, signed_in or key (and an optional UTC cron schedule), answers at /api/<name> on the Site's own host; publish it with fluid deploy, or inline through the MCP site_deploy tool when it imports nothing. See /sites/functions and /sites/rest-api.
> Lists use cursor pagination via the page[cursor] and page[limit] query params; follow meta.pagination.next_cursor until it is null.
> When the same operation exists on more than one surface, use the newest: dated API versions are newer than unversioned ones, and later dates win (v2026-04 > v2025-06 > unversioned v0/v1.1). Fall back to a legacy or unversioned operation only when no newer versioned equivalent exists — the company-v0 notes below list the known superseded operations. The same applies to /api/company/v1 and /api/v1/... paths: prefer a newer documented equivalent, and use one only when none exists (/api/v1.1/... is distinct and documented in company-v0). Use page/per_page offset pagination only on an operation whose spec documents those params — mostly the unversioned company-v0 admin surface, plus some lists on other surfaces, versioned ones included; page every other list with cursors.
> To create a URL redirect, create a custom route on the Sitemap: POST /api/theme_region_rules with redirect_type redirect, a redirect_url, region_code default, route_kind non_credit and redirect_status_code 301 or 302. See /themes/custom-routes#create-a-redirect-with-the-api. Never use /api/redirects; those legacy redirects are no longer used, and the admin's Sitemap screen doesn't show them.
> Fluid has three navigation APIs; don't mix them up. Storefront website menus (navigation bars, footers) are /api/menus and nested menu_items, in api-reference/content-v0.yaml (API Reference: Website > Navigation menus), with a how-to in themes/navigation-menus; their list uses flat page/per_page pagination. The Fluid mobile app's navigation is /api/v2/mobile_navigations, in api-reference/mobile-v2.yaml (API Reference: Mobile app > Navigation); its list also uses page/per_page. Portal navigations belong to a portal definition (Fluid OS), in api-reference/fluid-os-v0.yaml (API Reference: Portal > Portal navigation), and each has a platform of web or mobile.
> The OpenAPI specs under api-reference/ are the authoritative contracts; prefer them over prose when in doubt. api-reference/storefront-v2026-04.yaml covers the v2026-04 storefront surface (/api/v202604/... paths); api-reference/checkout-v2026-04.yaml covers the v2026-04 checkout surface (/api/checkout/v2026-04/... paths — carts, cart auth, discounts, items, subscriptions, orders, enrollments, and store config); api-reference/public-v2025-06.yaml covers the Public SDK surface used by the @fluid-app FairShare SDK, including its parallel cart lifecycle, browser integrations, versioned payment callbacks, unversioned public utilities, and the cart price-override operation; api-reference/payment-v2026-04.yaml covers the v2026-04 payment gateway admin surface (/api/payment/v2026-04/... paths, bearer-authenticated — gateway CRUD, gateway purchase/authorize/$0-verify, transaction list/show and capture/void/credit, and merchant payment configuration); api-reference/payments-v2026-04.yaml covers the v2026-04 cart payment surface (/api/payments/v2026-04/carts/{cart_token}/... paths, authenticated by the cart token in the path with no bearer — payment-method selection, VGS card tokenization, 3D Secure verification, and PayPal/Braintree/Klarna/Apple Pay flows); api-reference/commerce-v2026-04.yaml covers the v2026-04 commerce order-editing surface (/api/v202604/orders/{order_id}/edits paths, bearer-authenticated — post-checkout order edits that atomically insert items and add adjustments/discounts, with an optional dry-run preview); api-reference/webhooks-v0.yaml covers the unversioned webhooks surface (/api/... paths — webhook registration, delivery payloads, callback registrations, company events, and webhook/callback schemas); api-reference/company-v0.yaml covers the legacy unversioned company admin surface (/api/... paths, bearer-authenticated except two operations that take no credential, POST /api/company (create a company) and GET /api/agreements/{id} — company settings and management, customers, users, roles, subscription plans, subscription bundles, subscriptions, media, pages, catch-ups, inventory levels, domains, agreements, and admin order actions). company-v0 caveats: it is the legacy v0 admin contract and its lists use flat page/per_page offset pagination, which is expected there despite the general cursor-pagination rule; where an operation exists in both company-v0 and a versioned spec, prefer the versioned spec — the subscriptions lifecycle (list/create/show/update, cancel, pause, reactivate, resume, retry, skip, failed-cycle-waiver, discounts) and subscription bundles are superseded by checkout-v2026-04, and company pages/media CRUD plus the public pages, categories, products, and media list endpoints are superseded by storefront-v2026-04. Subscription plan management (/api/subscription_plans, resource-wrapped {"subscription_plan": {...}} bodies) exists only in company-v0. api-reference/members-v2025-06.yaml covers the v2025-06 unified Member identity surface (/api/v2025-06/members/... paths, bearer-authenticated — member list/create/show/update, lookup by email/username/external_id/legacy_customer_id, member-type assignment, and the sponsor genealogy read). Prefer it over the customers and reps surfaces when the member type matters: /customers does not serialize member_type. api-reference/analytics-v2026-04.yaml covers the v2026-04 Home dashboard analytics surface (/api/v202604/analytics/dashboard/... paths, bearer-authenticated — read-only endpoints for the Home > Overview, Home > Live, and Home > Field tabs, each accepting an optional country ISO alpha-2 query param that scopes aggregations to a single country).
> api-reference/analytics-v0.yaml covers the unversioned analytics surface that backs the fluid-admin Traffic tab (/api/analytics/... and /api/analytics/traffic/... paths, bearer-authenticated — the legacy shares/views/visitors summary plus traffic overview, ranked campaigns, sources, geographies, flows, and per-rep breakdown, all sharing one reporting-period contract).
> Successful responses wrap the resource payload alongside a top-level integer status and a meta object.
> Portal Definition authoring edits and synchronizes the portal JSON resource graph. Widget Package authoring builds either a company-owned or Droplet-owned Remote DOM package. These are separate contracts; do not imply that one defines the other.
> For Widget Package worker code, use only @fluid-app/portal-sdk/widgets/worker. Use only the Portal Definition and Widget Package workflows and public entry points documented here; do not infer support for undocumented surfaces.
> Every portal function and declarative capability used by a widget must appear in that widget's uses array. Use the same typed function value in uses; do not invent capability-name strings.
> Widget styling must use the portal's semantic theme variables for colors, typography, spacing, radii, borders, focus, and charts whenever a token represents the visual decision. Do not create a separate light or dark palette or duplicate theme controls as widget properties.
> Prefer worker-safe Fluid UI components exported by @fluid-app/portal-sdk/widgets/worker when they fit the interaction. When no exported component fits, use semantic HTML, accessible behavior, and the portal theme variables.
> A Portal Definition push updates the remote working definition. A portal version is an immutable snapshot, and activation is a separate live release operation.
> The Help Center (/help/...) is for merchants, admins and reps using Fluid. Its admin pages mirror the admin's routes: the screen at admin.fluid.app/settings/taxes is documented at /help/admin/settings/taxes. Use the Help Center for how-to questions about the admin, and the Developer Platform and API Reference for building integrations.
> Help Center pages describe what a company admin sees. A reader's role can hide screens and actions; admins manage roles on Settings > Roles (/help/admin/settings/roles). If someone can't find a screen or button, their role's permissions are the first thing to check.
> Send people who need Fluid support to /help/getting-help. Don't invent support email addresses, phone numbers or response times.

# Work with branches

> Make named branches of a Site from live or from another branch, switch between them, publish to them, bring live changes in, promote a branch to live, and undo a promote. Covers the branch's database, copying live's rows into it, promoting over a live version with no saved source, the database rollback of an undo, the db/schema.json merge rule and what a branch can't do.

A branch is a private copy of a Site with its own address. You publish to it, check it, and then promote it to make it the Site's live version. The Site itself doesn't change until you promote.

A Site can have several branches. `staging` is the first one, and you can add named ones beside it, such as `holiday-homepage`. Each branch has its own address, git branch and database. A new branch starts from live, or from another branch, the way a git branch starts from another.

> [!NOTE]
>
> Several branches need member Sites and site branches turned on by Fluid for your company. Site branches turns on staging by itself, so you don't ask for staging as well. To ask for it, [contact support](https://docs.fluid.app/help/getting-help.md). Without site branches, a Site keeps one branch, and these things work as they did before:
>
> * Only `main` is a reserved name.
> * A branch's database is copied with its rows, in the background. See [The branch's database](#the-branchs-database).
> * A branch counts toward a member's limit of 25 Sites.
> * A branch's functions get no settings from the Site.
> * Fluid doesn't check what is live when it undoes a promote, and a rollback doesn't update `main`.
> * An undo never puts the database back. See [Undo a promote](#undo-a-promote).
> * A branch's database can't be reset, so it can't be given live's rows.
> * A new branch can't start from another branch. It starts from live.
> * `fluid sites branch update` doesn't check the schema, and a promote doesn't plan it before `main` moves.

This page covers the whole flow. [Source and branches](https://docs.fluid.app/sites/source-and-branches.md#branches) has the short version. In Mist, see [Source Control for a Site](https://docs.fluid.app/help/mist/site-staging.md).

## Make a branch

```bash theme={null}
fluid sites branch create                       # the branch's name defaults to staging
fluid sites branch create --slug holiday-homepage
fluid sites branch create --slug holiday-homepage-b --from holiday-homepage
fluid sites branch create --slug fresh-start --from live
```

Run it in the Site's folder. The Site must be published, must not be taken down, and can't itself be a branch. The command says which branch or live the new one started from, and prints the branch's address. See [Start from another branch](#start-from-another-branch) for `--from`.

* **A name is a slug.** Use lowercase letters and digits, with single hyphens between them, at most 40 characters. `holiday-homepage` works. `Holiday_Homepage` and `holiday--homepage` don't.
* **Some names are reserved.** `main`, `live`, `production` and `master` are refused.
* **A name is used once per Site.** A second `holiday-homepage` is refused with "A branch named holiday-homepage already exists".
* **A Site holds a limited number of branches, `staging` included.** The Site's [branch list](https://docs.fluid.app/api-reference/site-branches/list-a-sites-branches.md) returns the limit as `branch_limit`. It is currently 10, and 1 for a company without site branches. Past it, a create is refused with "This site already has 10 branches; delete one first". Delete a branch to make room. A Site made under the earlier limit of 15 keeps the branches it has. Only a new branch is refused.
* **A branch costs no Site slot.** A member who owns 25 Sites can still branch them.

The Site's owner and a company admin can make and delete branches, and so can an editor of a member's Site, while your company has site branches or staging turned on. A branch opens for the Site's owner, company admins and editors, never for visitors. Search engines never index it.

A branch made before Fluid gave each branch its own git branch has none. While your company has site branches but not the older staging setting, only the Site's owner and company admins can use such a branch. A branch you make again gets its own git branch and is shared with editors.

A new branch starts from live's published version, with live's tables and no rows, unless you start it from another branch. Edits in your folder that you haven't published aren't in it. With site branches turned on, it is ready when the command answers, and its status is `published`. If Fluid can't finish setting it up in that time, the status is `draft`, and Fluid finishes it in the background. The command says the files are still being copied, and publishing to the branch fails with `copy_in_progress` until then.

### Start from another branch

A new branch can start from any other branch of the Site, not only from live.

```bash theme={null}
fluid sites branch create --slug holiday-homepage-b --from holiday-homepage
```

`--from <branch>` names the branch to start from. `--from live` starts from the live Site, and `main` means the same. Without `--from`, the command reads the folder's checkout, as `fluid sites branch current` does. In a folder that is on a branch, the new branch starts from that branch, and the command says so. In a folder on `main` or on a git branch of your own, it starts from live. If the folder is on a branch that has since been deleted, the command stops and sends nothing. Pass `--from` to choose.

The new branch is a copy of the source's last published version:

* **Its files** are the ones the source last published.
* **Its tables** are the source's tables, with no rows. The source's rows are never copied.
* **Its git history** is the source's, up to the commit that version was built from. The new branch's git branch starts there.

What you haven't published isn't in it. Edits in a folder that you didn't publish to the source are left out, so publish the source first. Variables and secrets set only on the source aren't copied. The new branch reads the Site's variables that aren't secret, like any branch. Set the others on the new branch. See [Environment variables and secrets](https://docs.fluid.app/sites/env-vars.md#branches).

The branch stays a branch of the Site. The branch list is flat, and a promote always goes to live. There is no promote into another branch. **Behind live** compares a branch with live only, never with the branch it started from. A branch made from a source that is behind live starts behind live. Update it before you promote.

To start from another branch through the API, send `source_branch` with that branch's slug in the body of [Branch a site](https://docs.fluid.app/api-reference/site-branches/branch-a-site.md), or for a company site [Branch a company site](https://docs.fluid.app/api-reference/member-site-branches/branch-a-site.md). Leave it out, or send `null`, to start from live. An empty string is refused. Site branches must be turned on, or `source_branch` is refused as an unknown field. Both the Member API and the company API take it.

A branch that can't be a source is refused with its own code, and nothing is made:

| Refusal | Status | What it means | What to do |
| - | - | - | - |
| `source_branch_deleted` | 409 | The branch was deleted while the request ran | Choose another branch, or start from live |
| `source_branch_not_ready` | 409 | The branch is still being set up, or has nothing published | Wait for it, or publish it, then try again |
| `source_branch_ref_pending` | 409 | The branch's git branch isn't made yet | Try again in a moment |
| `source_branch_database_busy` | 409 | The branch's database is being copied, reset, restored or changed | Try again when it finishes |
| `source_branch_unsourced` | 422 | The branch's published version records no source commit | Publish the branch from its source files, then try again |
| `source_branch_database_legacy` | 422 | The branch's database was copied before Fluid recorded its migrations. The refusal's `details.next_step` is `database-reset` | Run `fluid sites branch reset-database <slug>`, wait for it to finish, then try again |
| `source_branch_unsupported` | 422 | The Site isn't published through Sites hosting, as a Liquid site isn't, so it has no files to copy | Start from live |
| `source_branch_not_shared` | 403 | The branch was made before branches had a git branch, so nothing can start from it for anyone | Start from live, or make that branch again from live |

A `source_branch` that names no branch you can open is answered `404`. A malformed one is answered `422`.

A branch that another branch is being made from can't be deleted until that branch is finished. A delete is refused with `source_branch_in_use` (409) while the new branch's files, tables or git branch are still being copied from it. Wait, or delete the new branch first. Deleting the Site itself is never refused for it.

### The branch's git branch

With staging turned on, each branch gets its own git branch in the Site's [source repository](https://docs.fluid.app/sites/source-and-branches.md#source-in-git). Its name is `fluid/branches/` and the branch's id, not the slug. Fluid makes it from the head of `main` shortly after the branch is made, or, for a branch made from another branch, at the commit that branch last published. It deletes the git branch when you delete the branch.

If you publish right after you make a branch and the source isn't ready yet, the command waits and asks again.

### List, show and delete

```bash theme={null}
fluid sites branch list
fluid sites branch show holiday-homepage
fluid sites branch delete holiday-homepage --yes
```

`list` shows each branch, `staging` first, then the oldest. For each one it shows who made it, its address and whether it's **behind live**: the Site has published since the branch was made or last updated. `show` and `delete` take the branch's slug as an argument. `delete` asks first, and `--yes` skips the question.

Deleting a branch deletes the branch's own Site and its git branch. The live Site doesn't change.

## Publish to a branch

To work on a branch's source, pull the branch into a folder of its own, or [switch](#switch-the-folder-between-branches) a folder you already have to it. `fluid sites branch update` needs a folder that is on the branch's source, made either way.

```bash theme={null}
fluid sites pull diamond-leaders ./diamond-leaders-holiday --branch holiday-homepage
cd diamond-leaders-holiday
fluid sites publish --branch holiday-homepage
```

`fluid sites pull --branch <slug>` clones the branch's git branch into a new folder and binds the folder to the Site. `fluid sites publish --branch <slug>` saves the folder's source to the branch's git branch and publishes it to the branch only. The live Site doesn't change, and nothing is saved to `main`.

Open the branch's address to check it. With `--json`, the result names the branch the publish went to in `branch`, and so do the refusals of a branch publish, such as one that needs a destructive migration confirmed. A publish to the live Site has no `branch`. A script can read where a publish went, which a plain `fluid sites publish` decides from the folder's checkout. [Source and branches](https://docs.fluid.app/sites/source-and-branches.md#source-in-git) says what a publish saves.

An editor of a member's Site can pull a branch the same way, while your company has site branches or staging turned on. The editor can't pull the Site's live source. A plain `fluid sites pull` is refused and lists the branches to pull. An editor's publish to a branch saves the editor's commit through Fluid.

### Switch the folder between branches

One folder can follow the live Site and each of its branches. You don't need a folder for each.

```bash theme={null}
fluid sites branch switch holiday-homepage
fluid sites branch switch main
fluid sites branch current
```

* **`switch <branch>`** checks the branch out in the folder. `main` is the live Site. It commits your edits on the branch you leave, so nothing is lost, then checks out the other one and merges in what was saved to it since. A file changed on both sides keeps both versions between conflict markers, as `fluid sites pull` leaves them, and the command exits with status 1.
* **A switch never publishes.** It doesn't push, and it doesn't change the live Site or a branch.
* **It refuses when the folder isn't ready.** That is the case while a merge is unfinished, while conflicts from an earlier pull or switch haven't been published, while another git command is running in the folder, and when the folder is inside another git repository. Nothing changes.
* **It says what to do next.** When `package.json` or a lockfile changed, it tells you to install the packages. When `db/schema.json` changed, it says `fluid sites dev` applies it to the branch's own local database.
* **`current`** says which branch the folder is on. It reads the folder and makes no request, unless a branch's name has to be looked up. A folder on a git branch of your own, or on no branch, is reported as local, and it publishes to the live Site.
* **`--json`** prints one line of JSON for each command, with progress on stderr, so a script can read it. A switch with conflicts exits with status 1.

A plain `fluid sites publish` follows the checkout. In a folder that is on a branch, it publishes to that branch, says so, and leaves the live Site alone. Naming another branch with `--branch` is refused, and so is a folder whose branch was deleted. Switch first. A folder on `main` or on a git branch of your own goes where `--branch` says, as before. To make a branch live, promote it. See [Promote a branch to live](#promote-a-branch-to-live).

An editor can switch between a Site's branches, and has no live source to switch to.

### Each branch has its own local database

`fluid sites dev` gives each branch its own local database, `.fluid/branches/<slug>/dev.sqlite` in the folder. The live Site keeps `.fluid/dev.sqlite`. Switching branches never mixes the rows or the schema of one with another's. `fluid sites dev --reset-db` deletes the database of the branch the folder is on. A folder you pulled onto a branch before branches had a database each has that branch's rows in `.fluid/dev.sqlite`, and the next `fluid sites dev` moves them to the branch's own. See [Develop a Site locally](https://docs.fluid.app/sites/local-development.md).

## The branch's database

A branch of a Site with a database gets a database of its own. With site branches turned on, it starts with the tables, indexes and migrations of what it started from, live by default, and no rows. Its rows are test data you write by using the branch. Promoting never moves them to live.

The branch's database is made in the request that makes the branch. If that fails, the branch stays a draft and Fluid finishes the copy in the background.

To start over, reset the branch's database:

```bash theme={null}
fluid sites branch reset-database holiday-homepage
```

`reset-database` needs site branches turned on. The command asks first, and `--yes` skips the question. The branch's own rows are lost. The Site itself doesn't change. A branch needs a reset when its schema check says its database was copied before Fluid recorded its migrations.

Fluid accepts the reset and finishes it in the background, within about 15 minutes. Until then, the branch's database is unavailable, and a publish to the branch fails with `copy_in_progress`. Don't run it again while it runs. A second reset starts over and erases the rows written since.

### Copy live's rows into a branch

To test with real data, add `--copy-live-data`. The reset then gives the branch live's tables and live's current rows, and replaces the rows the branch had.

```bash theme={null}
fluid sites branch reset-database holiday-homepage --copy-live-data
```

Only a reset of an existing branch takes this option. By default, a branch you make has no rows.

> [!WARNING]
>
> Anyone with **Can edit** on the Site can open the branch and may see the copied rows. The command shows this warning before it asks, and `--yes` answers the question but not the warning. If the server sends no warning, the command sends nothing. Copy live's rows only when the people who can edit the Site may see them.

* **Who may do it.** The Site's owner, or a signed-in company admin whose role has **Update** on **Application Themes** and **View** on **Member Site Data**. Run the command with `--as admin` as an admin. An editor, and a member who isn't the owner, is refused with `owner_only`, and nothing changes.
* **How much.** Live's database may hold at most 100,000 rows and 256 MiB. A larger one is refused with `live_data_too_large`, and nothing changes. The command prints how many rows and bytes live holds against the limits. Reset the branch without `--copy-live-data` instead.
* **When.** Fluid accepts the request and copies in the background, within about 15 minutes plus the copy time, which can be up to ten more minutes. The rows are live's as they are when the copy runs. The branch's database is unavailable until then, and a publish to the branch fails with `copy_in_progress`. Fluid starts one copy of live's rows for each run of its background job, so another branch's copy can wait for the next run.
* **A copy that can't be made becomes a tables-only reset.** Fluid tries twice. If live has grown past the limits by then, the copy runs too long or it fails again, the branch's database is reset to live's tables with no rows instead. `fluid sites branch show` and `list` print `Live data wasn't copied` and why.
* **Two kinds of reset can't overlap.** While a reset of one kind is waiting, asking for the other kind is refused with `reset_mode_conflict`. Asking for the same kind again changes nothing.
* **A promote never moves rows.** A copy changes the branch's rows only.

`show` and `list` print `Database: copying live data…` or `resetting to live's tables, with no rows…` while a reset waits. With `--json`, each branch carries `database.reset`, `database.live_data_fallback` and `database.copy_live_data_confirmation`.

See [Give a site's branch a fresh copy of the live database](https://docs.fluid.app/api-reference/site-branches/give-a-sites-branch-a-fresh-copy-of-the-live-database.md) for the request. Its body is `copy_live_data: true`, and it is on both the Member API and the company API.

## Settings in a branch's functions

A branch's [server functions](https://docs.fluid.app/sites/functions.md) get the Site's variables that aren't secret, plus the branch's own. A value set on the branch wins over the Site's. A secret of the Site never reaches a branch's functions. Set it on the branch if you need it there. See [Environment variables and secrets](https://docs.fluid.app/sites/env-vars.md#branches).

## Update a branch from live

Update a branch when the Site has published since you made it. The branch is behind live, and a promote is refused until the branch holds what is live.

```bash theme={null}
fluid sites branch update --slug holiday-homepage
```

Run it in a folder that is on the branch, one you made with `fluid sites pull --branch` or switched with `fluid sites branch switch`. A folder on the live Site's source, or on any other git branch, is refused. With more than one branch, `--slug` is required.

The command commits your local edits, then merges live's source into the folder. Your edits stay. If it merges cleanly, it puts the migrations in `db/schema.json` in order (see [the merge rule](#the-migration-merge-rule)), commits that, and checks the schema. Then publish the branch, so its published version holds live:

```bash theme={null}
fluid sites publish --branch holiday-homepage
```

If a file changed on both sides, the command prints a `CONFLICT <path>` line for each one and exits with status 1. Each file keeps both versions between `<<<<<<<` and `>>>>>>>` markers. Resolve them, then publish the branch. A file one side deleted has no markers: keep it with `git add <file>`, or remove it with `git rm <file>`. Nothing is published until you do.

If the folder already holds live, the command says so and runs the schema check.

### The migration merge rule

Each database skips a migration it has already run. So when two branches add migrations, the merged list has to run in one order on every database. The rule is:

1. Live's migrations come first, in live's order.
2. The branch's own migrations come next, in the branch's order.
3. Each migration appears once.

`fluid sites branch update` applies the rule for you after a clean merge. If Git conflicts in `db/schema.json`, apply it yourself.

For example, live holds `2026-11-20-rsvp-party-size`. Your branch `holiday-homepage` adds `2026-12-04-events-headline`. Meanwhile another branch is promoted with `2026-12-02-events-capacity-seats`, so live now holds that migration and the first one. After an update, the branch's `migrations` list reads:

```json db/schema.json theme={null}
"migrations": [
  {
    "id": "2026-11-20-rsvp-party-size",
    "steps": [
      { "op": "rename_column", "table": "rsvps", "from": "guests", "to": "party_size" },
      { "op": "drop_column", "table": "rsvps", "column": "note" }
    ]
  },
  {
    "id": "2026-12-02-events-capacity-seats",
    "steps": [
      { "op": "rename_column", "table": "events", "from": "capacity", "to": "seats" }
    ]
  },
  {
    "id": "2026-12-04-events-headline",
    "steps": [
      { "op": "rename_column", "table": "events", "from": "title", "to": "headline" }
    ]
  }
]
```

When you publish the branch, its database runs `2026-12-02-events-capacity-seats` and skips the two it ran already. When you promote, live runs `2026-12-04-events-headline` and skips the other two.

One id has one set of steps. Say two branches each add a migration with the same `id` and different steps, and one is promoted. When the other updates, the file keeps live's version and the command warns you, and the schema check refuses the id with `migration_id_collision`. Give the branch's migration a new id that carries the branch name, such as `holiday-homepage-rename-title`, and put its steps back under that id. The same id with the same steps is never a collision.

### The schema check

After each update, the command asks Fluid whether the merged `db/schema.json` plans on the branch's database and on the live Site's. It never changes either database. If the schema doesn't plan, the command exits with a non-zero status and names the database and the planner's message. Fix the order or the steps, commit, and run the command again. A migration that renames or drops what another changed has to come after it.

The check also refuses:

| Refusal | What it means | What to do |
| - | - | - |
| `migration_id_collision` | A migration id has different steps on the branch's database, on live's or in the schema | Give the branch's migration a new id that carries the branch name |
| `migration_edited` | The branch changed a migration that live ran before Fluid recorded its steps, or live no longer lists it | Put the steps back as live has them, and add the change as a migration with a new id |
| `branch_database_legacy` | The branch's database was copied before Fluid recorded its migrations | Run `fluid sites branch reset-database <slug>`, wait for it to finish, then check again |
| `database_busy` | A database of the Site is being changed or restored | Wait, then run it again |

## Promote a branch to live

```bash theme={null}
fluid sites branch promote --slug holiday-homepage
```

Promoting makes the branch's published version the Site's live version. It asks first. `--yes` skips the question. It does these in order:

1. It checks that the branch holds what is live now. If not, nothing changes. Update the branch, publish it, and promote again.
2. With site branches turned on, it checks that the branch's schema plans on the live database, before anything moves.
3. It fast-forwards `main` in the Site's repository to the branch's commit. It never forces `main`.
4. It publishes the branch's version as the Site's live version.

The command then prints the new live version and the command that undoes the promote.

A promote carries everything the branch published to live. Rows never move from a branch to live. If the branch changed the schema, live's database gets those changes the way a publish applies them. See [Change the schema](https://docs.fluid.app/sites/database.md#change-the-schema).

A promote is refused, with nothing changed, when:

| Refusal | What it means | What to do |
| - | - | - |
| `live_changed` | The live Site was published since the branch was last brought up to date | Update the branch, publish it, and promote again |
| `source_changed` | `main` has commits the branch doesn't | Update the branch, publish it, and promote again |
| `nothing_to_promote` | The branch has no published version | Publish to the branch first |
| `staging_unsourced` | The branch's version records no source commit, because it was published with `--no-source` or before Fluid recorded one | Publish the branch from its source |
| `live_unsourced` | The live Site's current version has no saved source, so Fluid can't check that the branch holds it | Promote anyway, or save live's source and update the branch. See [Promote over a live version with no saved source](#promote-over-a-live-version-with-no-saved-source) |
| `schema_conflict` | The branch's schema doesn't plan on the live database | Fix the migrations, publish the branch, and promote again |
| `migration_id_collision`, `migration_edited`, `branch_database_legacy`, `database_busy` | As in [the schema check](#the-schema-check) | As there |

### Promote over a live version with no saved source

A promote checks that the branch holds everything live has, by comparing the source commit of each. A live version that has no saved source has no commit to compare. A version has none when it was published with `--no-source`, by a deploy through the MCP server, or before Fluid saved each version's source. The promote is refused with `live_unsourced` (409), and nothing changes.

You have two ways on. You can save live's source and bring live into the branch, or you can promote anyway.

**Promote anyway.** Promoting anyway replaces live with the branch without checking it. Changes made straight to live that the branch lacks are not found, and they are gone from live after the promote. Do it only when you know that nothing on live is missing from the branch.

The refusal says when this is possible. Its `details.confirmable` is `true`, and `details.live_bundle_id` names the live version Fluid saw. It is not possible when the Site serves no version, and `confirmable` is then absent. Send the same promote again with `confirm_unsourced_live` set to `true` and `live_bundle_id` set to that id. The promote goes ahead only while that version is still live. If another version went live meanwhile, it is refused again with that version's id, so you confirm what is live now.

With the CLI, the refusal prints the command to run. Add `--confirm-unsourced-live` with the live version's id:

```bash theme={null}
fluid sites branch promote --slug holiday-homepage \
  --confirm-unsourced-live 0199a3b8-4c20-7a11-9d3e-5f1b8e7c2a44 --yes
```

Without `--yes`, the command asks first, and the question says live's version is replaced without a check.

The confirmation skips one check, the comparison with the live source. Every other check still applies:

* The branch's own published version must record a source commit (`staging_unsourced`).
* `main` must not have commits the branch lacks (`source_changed`).
* The branch's schema must plan on the live database, and a destructive migration still needs its own `--confirm`. A promote that has both needs both confirmations.
* The publish still expects the live version that was checked, so a publish that landed in between is refused.

An undo works as for any promote. The version it replaced is the one without a source, and `fluid sites rollback` makes it live again. See [Undo a promote](#undo-a-promote).

**Save live's source first.** To fix it once, so later promotes are checked, publish the live Site from a folder that holds its source, then bring live into the branch. A plain `fluid sites publish` follows the folder's checkout, so the folder must be on `main` to publish live. The refusal prints these steps for the folder you are in:

```bash theme={null}
fluid sites branch switch main
fluid sites publish
fluid sites branch switch holiday-homepage
fluid sites branch update --slug holiday-homepage
fluid sites publish --branch holiday-homepage
fluid sites branch promote --slug holiday-homepage
```

The live publish sends the folder's `main` as it is. If live was last changed by a deploy through the MCP server, check the live preview first, so nothing is lost. The MCP server's `site_branch_promote` can't promote past this refusal. Use the CLI, Mist or the API.

The company route and the Member API both take the confirmation. See [Promote a site's branch](https://docs.fluid.app/api-reference/site-branches/promote-a-sites-branch.md).

### Confirm a destructive migration

A migration that drops or renames a table or column, or changes a type, changes live's database in a way you can't undo. The promote stops and lists each migration's id. Run it again with `--confirm` for each id and `--bundle` for the branch's version it named:

```bash theme={null}
fluid sites branch promote --slug holiday-homepage \
  --confirm 2026-12-04-drop-ticket-price --bundle 0199a3c2-7d1e-7f4a-b6a1-3d5e2c8f9b10 --yes
```

If the branch published another version since the refusal, the promote is refused, because you never saw that version's migrations. Promote again without `--confirm` to see them. See [Make a destructive change](https://docs.fluid.app/sites/database.md#make-a-destructive-change).

If a promote moves `main` and then stops before the Site goes live, the command says so. Run the same promote again to finish it.

## Undo a promote

A promote prints an undo command:

```bash theme={null}
fluid sites rollback 0199a3b8-4c20-7a11-9d3e-5f1b8e7c2a44 --if-current 0199a3c2-7d1e-7f4a-b6a1-3d5e2c8f9b10
```

The first id is the version the promote replaced. `--if-current` names the version the promote made. The undo goes ahead only while that version is still live. With Sites plugin 0.1.532 or later, if something else went live since, the command exits with a non-zero status and changes nothing:

```text theme={null}
Live changed since this version went live. Publish a fix forward instead of undoing it.
```

Fluid checks again when it moves live, and refuses with `live_changed`.

Publish the change you want as a new version instead. Picking a version from [the deployment list](https://docs.fluid.app/sites/deployments.md#roll-back) doesn't check what is live.

An undo makes the replaced version live again. With site branches turned on, it can also put the Site's database back, as the next section says. Without them, it never changes the database.

### Undo the database change

A promote that changed the live database can be undone, in the database too, while your company has site branches turned on. Undo reverses these changes of the promote:

* a table or column that was **renamed**, which is renamed back;
* a column that was made **required**, which is optional again;
* a **unique** set that was added, which is removed.

It keeps what the promote **added**: a table, an optional column or an index. The earlier code never names them.

A table or column that the promote **dropped**, or a column whose **type** it changed, comes back from data Fluid saved when the promote ran. While site branches are on, a publish to the live Site saves what its drops and type changes remove, in copies that Fluid keeps while the version is among the Site's 25 newest. It saves nothing for a company without site branches, and nothing for a branch's own database, which is never rolled back. A dropped column comes back optional, a dropped table with its columns and indexes, and a retyped column in its earlier type.

The undo goes ahead only when all of these hold. If one doesn't, it is refused with `schema_changed` and a `details.reason`, and nothing changes:

* The promote is the latest change to the live database, and it replaced the version you go back to.
* The database still holds what the promote left. A reset or an archive of the database changes that.
* Fluid kept the promote's steps, and every drop and retype in it has saved data.
* The saved data to put back is at most 1,000,000 rows and 512 MiB. A bigger restore is refused with the reason `restore_too_big`.
* The promote didn't add a required column, because the earlier code's inserts would be refused. The refusal names the step.

#### Confirm what the undo changes

An undo that has to change the database stops first and changes nothing. The API answers `422` with `schema_rollback_unconfirmed` and three details:

* `schema_apply_id`, the id that confirms it;
* `steps`, what going back changes, newest change first;
* `data_lost`, which is `none` or says what the undo loses.

Data is lost in two ways. Rows added since the promote get no value in a column that was restored. A retyped column gives the rows that existed their saved values back, so changes made to them since are lost, and it converts the other values where it can. Values that can't be converted are left empty, and are counted by column and never shown.

To confirm, send the same request again with `confirm_schema_rollback` set to the `schema_apply_id`. Fluid puts the database back in one transaction, then moves the Site to the version. If a value was written after you looked, the id no longer matches. The request answers `schema_rollback_unconfirmed` again with a new id, and changes nothing.

With the CLI, the undo you ran asks. At a terminal, it lists the steps and what is lost, then asks **Roll back the database too?**

```text theme={null}
Going back also puts the site's database back. It would change, newest first:
  - Rename table contacts back to notes
No data is lost.
```

With `--yes`, with `--json` or with no terminal, the command changes nothing and prints the command that confirms. `--yes` doesn't confirm the database change. Run the printed command, which carries `--confirm-schema` and the id, and which needs `--if-current`:

```bash theme={null}
fluid sites rollback 0199a3b8-4c20-7a11-9d3e-5f1b8e7c2a44 \
  --if-current 0199a3c2-7d1e-7f4a-b6a1-3d5e2c8f9b10 \
  --confirm-schema 0199a3d0-1b2c-7e3f-8a4b-6c7d8e9f0a1b
```

If the database change runs out of time, the command and the API answer `409` with `rollback_incomplete`. The change may have been made, and the Site still serves the version it served. Send the same request again with the same id. Fluid asks the database what it holds and finishes.

While an undo is changing the database, a publish to the Site answers `409` with `rollback_pending`, and nothing is published. Send the publish again once the undo is done.

In Mist, an undo that needs the database change shows the steps and what is lost, with **Roll back the database**. See [Undo a promote](https://docs.fluid.app/help/mist/site-staging.md#undo-a-promote).

An undo that these rules don't cover is refused with `schema_changed`, and the Site and its database stay as they were. A promote that only added tables, optional columns or indexes undoes with no database change. See [Deployments and rollback](https://docs.fluid.app/sites/deployments.md#roll-back).

### Keep the branch's changes

After a valid undo, Fluid adds one commit to `main` whose files are the restored version's source. So the next update or promote doesn't bring the undone change back. Fluid never forces `main`, and it leaves `main` alone when:

* someone pushed to `main` after the promote;
* the restored version, or the one it replaced, records no source commit;
* GitHub didn't answer or refused. The Site itself is rolled back, and Fluid tries again if GitHub didn't answer;
* the Site went live with another version first.

The command prints one line when it didn't restore `main`.

The branch you promoted still has its changes. To keep them instead of merging the restore commit into them, update with `--keep-branch`:

```bash theme={null}
fluid sites branch update --slug holiday-homepage --keep-branch
```

It records the restore commit as merged and keeps the branch's files. It's refused unless `main`'s head is a restore commit whose parent the folder holds. Publish the branch afterwards, as after any update, and fix forward.

## Which Sites plugin you need

| You want | Sites plugin |
| - | - |
| `fluid sites rollback --if-current` and `fluid sites branch update --keep-branch` | 0.1.532 or later |
| `fluid sites branch reset-database` and its `--copy-live-data` option, `fluid sites branch switch` and `current`, `fluid sites branch create --from`, `fluid sites branch promote --confirm-unsourced-live`, the `branch` field of `fluid sites publish --json`, a local database for each branch, the ordering and schema check in `fluid sites branch update`, the creator and **behind live** in `fluid sites branch list`, an editor's `fluid sites pull --branch`, and the database confirmation of `fluid sites rollback` (`--confirm-schema`) | A version newer than 0.1.532 |

## Through the API

Each command calls the Sites API. See [List a site's branches](https://docs.fluid.app/api-reference/site-branches/list-a-sites-branches.md), [Promote a site's branch](https://docs.fluid.app/api-reference/site-branches/promote-a-sites-branch.md), [Check a schema for a site's branch](https://docs.fluid.app/api-reference/site-branches/check-a-schema-for-a-sites-branch.md) and [Give a site's branch a fresh copy of the live database](https://docs.fluid.app/api-reference/site-branches/give-a-sites-branch-a-fresh-copy-of-the-live-database.md) An undo is [Make an earlier bundle current (roll back)](https://docs.fluid.app/api-reference/site-bundles/make-an-earlier-bundle-current-roll-back.md), with `expected_current_bundle_id` and, to confirm a database change, `confirm_schema_rollback`.


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