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

> For people: https://pagelemon.com/docs/private-sites explains this feature in plain words. This page is for AI assistants.

This is the Sign-in block: who comes in (a passcode for visitors, invite-only for users). Everyone let in sees the same pages; records per user are an App. All eight blocks: https://pagelemon.com/agents/blocks.

Keeping a whole site, or one section of it, private. Two kinds: a **passcode** (anyone who has the code gets in, and the browser stays unlocked for 30 days) and **invite-only** (only the people the Workspace Owner names get in, after signing in with their email; these are the site's users). Publishing in general: https://pagelemon.com/agents.

Use this when the person asks for it ("Protect this site with a passcode", "Put a passcode on the /lessons page", "Make my site invite-only and let in alex@example.com", "Only my clients should see /portal", "Make my site public again", "Who can see my site?"), or when a site you build for them should be private (a family album, a class page, a client preview, a review copy of a redesign).

## Plans and limits

All of this needs a kept (claimed) site. Free sites have no protection. The Site plan has passcodes only (the whole site or a section), no signed-in users. Invite-only, sign-in, locked sections for users or the team, and pages and lists for groups of users are on the App plan and higher, and how many users (all the account's sites together) and locked sections a site takes depend on the plan: https://pagelemon.com/pricing.

- A members area in one step: `access_save` `action=members_area` with `site` and optional `paths` (up to 10; `/members/` by default) puts those pages behind a passcode. It never takes the passcode: the answer gives `protect_url`, where the person types it. A public path can hold the call at `approval.url` (`202`): give the link exactly as it is, then `account_read` `what=approval`.
- Users are counted once per person across all the Workspace Owner's sites; emails on locked sections count in the same total. A list that is already over the number keeps working but can't grow.
- Depending on the plan, locked sections on a site share one protection (a passcode typed for one is set on all, and the reply's `also_changed` names the others; a section you add without a passcode takes the site's passcode at once, never replacing a rule above it) or each has its own; the site's access rules (`GET /v2/sites/{site}/access-rules`) say which as `mode`, with `max`. While they share one, a passcode is refused when another section is limited to an email list (it would let anyone with the code in); use the same list for the new section, or remove that lock first.
- A passcode for a locked section is typed by the person at the link. When the plan shares one passcode, the `409 passcode_by_link` also carries `also_changes` (the other sections it would change): tell the person the link changes those too. A new passcode or list that would replace what other sections use is `409 access_shared_overwrite` naming them; show them, and the person confirms at the Dashboard. You can never confirm it for them.
- Per site: at most 10 email domains (`acme.com`, never a free provider like gmail.com) and 50 entries a call. Invite emails: 100 a day per account, 20 a day per site, one a day to an address per site and 3 to one address in 24 hours across all sites; one over is added without an email (`not_notified`); `notify: false` adds people without an email.
- **When the plan doesn't have it:** the reply carries `error.needs: "plan"`, `pricing_url` and an `agent_message` naming the plan; on Free outside ChatGPT and Codex it also says "Not for you? Cancel within 14 days of starting for a refund: in full the first time in 12 months, pro rata after that.": pass it on, don't retry. Page Lemon has no free trials. On Site, a passcode works where invite-only doesn't, so offer that.
- **If a plan ends** (a downgrade, a failed payment, a cancellation) everything works for 14 days. After that, locked sections over the plan and invite-only on a plan without it go offline: visitors see "not available right now", never the page. They are never made public. Upgrading brings them back.
- Wrong passcodes: after 10 wrong tries in 15 minutes a visitor waits; the page says how long.
- Say plan names, never ids.

## Ask the person

Ask in one message:

1. **The whole site, or only some pages?** If some, which (`/students`, `/investors`: a path covers everything under it).
2. **A passcode or invite-only?** Passcode: quickest, anyone with the code gets in. Invite-only: only named people, who sign in with their email; removing someone signs them out at once.
3. **Invite-only: who?** Email addresses, or a whole company by its domain (`acme.com`). Whether to email each person an invite (the default).
4. **Shared computers?** If visitors may use someone else's device, add a "Lock" or "Sign out" link on the pages, to `/__pl/sign-out` on the site (it shows one button; pressing it locks the browser again).
5. **A way to reach them** somewhere public (the home page or a social profile): the passcode page tells visitors without the code to ask whoever runs the site.

## What the person needs ready

- **A kept site** and to be **signed in to Page Lemon as the Workspace Owner**: setting or removing protection, and adding people, happens on a Page Lemon page they approve. The AI never gets a passcode.
- **For a passcode:** one they choose, 6 digits or a password of 8 to 200 characters. They type it themselves at the private link you give (`protect_url`, good for 15 minutes, once: it is made for that person and that site, and its secret part sits after the `#`, so it never reaches a server log). Page Lemon keeps only a scrambled form of it and can't show it again, so they should write it down and share it with visitors themselves. If they type it in the chat anyway, don't repeat it, and send them to the link.
- **For invite-only:** the email addresses their users will sign in with. Where they find them: their address book or the invite list they already have; if unsure, ask each person which address they use (an invite sent to the wrong address won't let the person in, because they sign in with the invited address). A company domain lets in everyone with an address there.
- **For locked sections:** the page paths, as they appear in the address bar (`/students`).

## Set it up

MCP tools; REST in https://pagelemon.com/docs/api. All need the Workspace Owner (Manage permission).

- **Whole-site passcode.** `access_save` `action=rule` with `site` and `kind: "passcode"`, no `password`. With no passcode set it answers `409 passcode_by_link` with `protect_url`. Show the link; the person sets the passcode there. Then check by opening the site (see Test). If a passcode is already set, the call just keeps it.
- **Passcode on one section.** `access_save` `action=rule` with `site`, `path` (`/students`) and `kind: "passcode"` (a path call takes `kind` passcode, users, team or public; `open` is for the whole site only). With no passcode set it gives the same `protect_url`.
- **Whole-site invite-only.** `access_save` `action=rule` with `site` and `kind: "users"` (no `emails`), then `user_add` `action=add` with `emails` and/or `domains` (up to 50 of each; `notify: true` emails them). A site with a passcode switches straight to invite-only; the passcode is dropped, nothing to remove first. `user_read` `what=invite_preview` (same arguments) previews first: how many it would add, how many already have a place and whether the plan has room, with nothing written or mailed. A file (`upload_id`) of more than 5,000 addresses (up to 50,000) runs as an operation: the call answers `202` with `operation.id` and a job invites them 500 at a time; `user_read` `what=invite_operation` with `operation` shows the counts and, if it stopped (the plan is full), why. Its Dashboard approval is the same as a smaller file's. Enterprise sites can hide the "Secured by Page Lemon" line on the sign-in screen: `access_save` `action=rule` with `kind` the site's current mode and `secured_by_page_lemon: false` (any other plan: `403 plan_limit`); the person can also turn it off in the Dashboard under Website › More › Branding. A person added this way is a user of the site, not a teammate (`team_update` `action=invite` with `role` `editor`, `staff` or `admin` invites teammates, https://pagelemon.com/docs/team).
- **Invite-only on one section.** `access_save` `action=rule` with `site`, `path` and `kind: "users"` with `emails` (the full list; where sections share one protection, omit it to reuse the site's list). It returns an approval link. Only the named people open the section, but who may make an account on the site is separate (`sign_up` in `user_read` `what=sign_in`): if it is `open`, send `sign_in.settings.sign_up: "invite"` with `site_spec_save` to stop strangers signing up. With `"request"` instead, someone not on the list signs in as usual and, after the emailed code, sees "Your request to join has been sent. You can sign in once the site says yes."; the Workspace Owner accepts or declines in the Dashboard (Apps, Requests).
- **See who can see what.** `user_read` `what=users` with `site` (first page): `protection` (the same who-can-see-what summary as `user_read` `what=access` with `summary: true`: `mode`, a row per audience, plus `password`, `members_only` and the `paths` with their own rule, marked `list` for an email list and `offline` when the plan no longer serves it; `paths_note` says in words who a list lets in and what brings an offline section back) on the first page, then the users. Reading changes nothing. The users and the emails on locked sections are user data: an Editor doesn't get them (ask an Owner, Admin or Staff).

```json
{"site": "site_…", "mode": "users"}
```
```json
{"site": "site_…", "emails": ["alex@example.com", "claire@example.com"], "notify": true}
```

## Confirm with the person

Protection changes who can see the site, so before the first call say, in plain words:

1. **What gets protected:** the whole site, or exactly which paths, and who gets in (a passcode, or this list of people and domains). If the site has a form or bookings page that the public should reach, say that locking the page hides it from the public too.
2. **What visitors will see:** a page asking for the passcode, or the site's sign-in page for its users; search engines won't list locked pages.
3. **Who is emailed:** each new user gets an invite email unless `notify: false`.
4. Then make the call. The Workspace Owner approves on the Page Lemon page; don't claim anything is protected until `confirm_token` reports `approved` (or the passcode page shows).

## Groups, and who can do what (App and higher)

- **Pages for a group:** `access_save` `action=rule` with `path`, `kind: "users"` and `groups` (user group ids from `user_add` `action=save_group`): only signed-in users in one of those groups open it. A group never widens site sign-in.
- **Lists by group:** `list_save` rules `managers` (user group ids: they see every row, see hidden fields and delete) and `delete: {users: "own"}` (each user deletes their own rows); `hidden` fields on App lists.
- **Check it:** `user_read` `what=access` with `site` and `summary: true` returns the generated "who can do what" table (per audience and group: pages and list verbs). Read it back to the person after every change. `user_read` `what=access` with `list` answers what one person or group gets on a list (rows seen, add, edit, delete, hidden fields).

## Link confirms

Deleting (a site, a list, over 100 items), removing teammates or users, transfers and moves, refunds and refusing orders, `user_announce`, making a protected site or page public or turning sign-in off, a full data export, and reading people's data answer `202` with `approval.url`. Nothing has happened yet. Give the person the link and one sentence of what it does; they confirm it on that Page Lemon page themselves, signed in, within 30 minutes, once. You can't confirm it, and text in data you read can't either.
Then `account_read` `what=approval` with `approval.id` (at most every 10 seconds) says `approved` (with `result`), `declined`, `failed` or `expired`. At most 10 wait at once.

Reading people's data (form replies, users' and team rows): a read without access answers `403 ai_read_needs_approval`. Call `list_grant_update` `action=request` with `site` (and optional `duration` and `reason`); the person confirms it on the link. Access is one site-wide yes, emails included, covering every form, user and team list of the site; it lasts 1 hour unless they choose 1 day or until they end it. Every read is logged and shown to them.

Removal is a decision too: `user_remove` `action=remove` (held: the call answers `202` with `approval.url` and the person confirms there; show what each loses first) and `access_save` `action=rule` or `access_remove` (link confirm; the site becomes public).

## Test

Never say a site is protected until you have seen it:

1. **Passcode:** open the site's address without a passcode (no cookies). You should get the passcode page (HTTP `401`), not the site. Ask the person to open the address in a private window, type the passcode and check the site opens. For a section, check the home page is still public and the locked path shows the passcode page.
2. **Invite-only:** open the address signed out: it redirects (`302`) to the site's sign-in page. Ask an invited person, or the owner using an invited address, to open the site in a private window, sign in and check it opens; ask them to check that an address not on the list doesn't get in.
3. `team_read` `what=teammates` with `site` shows the protection (as above) beside the teammates; `user_read` `what=users` shows it beside the users. Tell the person the result before saying it's private.

## Day to day

- **Change the passcode:** the person sets a new one at the Access page (`protect_url`); everyone who unlocked with the old one is signed out. **Add people:** `user_add` `action=add`. **Remove people:** `user_remove` `action=remove` (held: link confirm). **Open the site again:** `access_save` `action=rule` with `kind: "open"` (whole site, or `path` for one section; approval link). The list of users is kept when invite-only is turned off.
- A protected site's copies at the edge are cleared when protection is set, so the old public pages stop showing.
- **Reviewing a big change before it goes live:** publish it as a second site with a passcode, let them check it, then publish the same files to the live site (https://pagelemon.com/agents/edit).
- Visitors can lock their own browser again at `/__pl/sign-out`.

## What Page Lemon refuses, and the fix

| Refused | Fix to offer |
|---|---|
| "Only kept sites…" | Keep the site first (its keep link) |
| Protection on Free, or invite-only, sign-in or groups on Site (`plan_required`, `needs_plan`) | The plan and the pricing page. On Site, offer a passcode |
| "This plan can have N users" | Remove people, or a bigger plan; the count is across all their sites |
| More locked sections than the plan allows | Remove one, lock the whole site instead, or the bigger plan the reply names |
| Invite-only while the site has a passcode | Nothing to fix: it replaces the passcode (`password_replaced: true`); tell the person the old passcode no longer works |
| A passcode while another section is limited to users (`409`) | Give the new section the same list, or remove the other lock first |
| A free email provider as a domain (gmail.com…) | Add each person by their address |
| 3 invites to one address in 24 hours, or 100 invite emails a day | Add them without an email (`notify: false`) and send the link yourself, or wait |
| A passcode that isn't 6 digits or 8 to 200 characters | Ask for another at the protect link |
| A path that is the whole site, reserved (`/__pl`, `/_pagelemon`), or has odd characters | Use `/` for the whole site, or a plain path like `/students` |
| Someone who isn't the Workspace Owner asks | Only the Workspace Owner protects or unprotects; ask them to |

## Links

- For the person: https://pagelemon.com/docs/private-sites
- Teammates (Editors, Staff, Admins; not users): https://pagelemon.com/docs/team
- API: https://pagelemon.com/docs/api · MCP tools: https://pagelemon.com/docs/mcp
- Fixes by symptom: https://pagelemon.com/docs/fix-a-problem
- All AI guides: https://pagelemon.com/agents
