<!-- Built by scripts/build-agent-docs.mjs from site/agents-src/staging.md: edit that file. -->
# Page Lemon staging: guide for AI assistants

> For people: staging is on the site's page in the Page Lemon app (Versions tab, Staging). This page is for AI assistants.

A staging copy is a private copy of a live site at `staging--<name>.pagelemon.dev`, where you try changes to the pages, lists, forms, booking, Checkout and Apps before they go live, then promote them. Only the workspace's people can open it, after signing in with their Page Lemon login.

Use this when the person says "set up a staging site", "try this on a copy first", "test the new booking setup before customers see it", "don't change the live site yet". For a design change only, a preview link is lighter and works on every paid plan (`publish_site` with `preview: true`; https://pagelemon.com/agents/publish).

## Plans and limits

A staging copy (one per site) is for workspace sites and for personal sites with an App, on every paid plan (https://pagelemon.com/pricing). It is counted with the workspace's storage, each file once (a fresh copy adds nothing), and takes no site slot.

- Free, or a personal site without an App, has none: the reply is `forbidden` with `pricing_url`: tell the person, offer a preview link, never retry.
- The live address must be 54 characters or fewer.

## Ask the person

Nothing is needed to turn it on. Before you promote, ask: "Shall I make these staging changes live now? Only the files, or also the list items you changed there?"

## What the person needs ready

Nothing. To open the copy they sign in with their Page Lemon login on the staging address; people outside the workspace can't open it.

## Set it up

- Turn it on: MCP `save_site_settings` `{site, staging: "on"}` (REST `POST /v2/sites/<site>/copies`). The reply has `staging.url`.
- What it is now: `get_site {site}` shows `staging` (on, address, staging version, files changed, `live_changed`); `get_site {site, staging: true}` reads the copy itself.
- Change it: `deploy {site, staging: true, base_revision: <staging's live_revision.id from get_site staging: true>, patch: true, files: [...]}`.
  Lists, forms and bookings on the copy: the usual tools with `site: "staging--<name>"`.
- Test Apps as a user: `preview_as_user {site: "staging--<name>"}`. Test people, the access map and the captured outbox: https://pagelemon.com/agents/testing.

## What is in the copy

- Copied: the live files, settings, page locks, content lists with their items, and the setup of forms, booking, Checkout products and Apps.
- Empty: users and their data, form replies, bookings, orders, visitor numbers. Tell the person; never copy people or messages into it.
- Off: custom domains, calendar connections, webhooks, API keys, real payments, emails to anyone outside the workspace, search engines.

## Confirm with the person

Promoting changes the live site. Show what changes (`staging.files_changed`: added, changed, removed, with paths) and ask before `site_settings {site, staging: "promote"}`; add `rows: true` only when they want the list items too.

## Test

- Payments on staging are simulated: a pay, donate or join button opens a dialog **Simulate: paid / cancelled / failed**; the rest (thank-you page, order, stock, user plan, receipt to the workspace's people) runs as on the live site, with no money and no Stripe.
- Emails from staging reach only the workspace's people; anything addressed to someone else is not sent (say so if the person tests a form with a customer's address).
- After promoting, open the live site and check the changed pages; tell the person what you checked.

## Day to day

- `site_settings {site, staging: "refresh"}`: copy the live site again (staging's earlier versions stay in its history).
- `site_settings {site, staging: "promote", rows?: true}`: staging's files become the next live version (the history shows "promoted from staging").
- `site_settings {site, staging: "off"}`: delete the copy and its test data; the live site doesn't change.

## What Page Lemon refuses, and the fix

| Refusal | What to do |
|---|---|
| `forbidden`, the plan has no staging | Offer a preview link instead, or tell the person the plan (pricing link in the reply) |
| `conflict` on promote (the live site changed since the copy) | Ask: refresh staging and redo the change there, or replace the live change: promote again with `base_version` = the live revision in the reply |
| `bad_request` "isn't available on a staging copy" (domain, rename, archive, people, plans) | Do it on the live site; staging follows it |
| `not_found` "Staging is off" | Turn it on first |
| `bad_request` the address is too long | Rename the live site to 54 characters or fewer, then turn staging on |

## Links

- Contract: `save_site_settings`, `publish_site` and `get_site` in https://pagelemon.com/agents (MCP tools); staging over REST: `GET` and `POST /v2/sites/<site>/copies`.
- Preview links: https://pagelemon.com/agents/publish. Workspaces: https://pagelemon.com/agents/workspaces. All guides: https://pagelemon.com/agents. User doc: https://pagelemon.com/docs/staging.
