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

> For people: https://pagelemon.com/docs/pages, https://pagelemon.com/docs/lists, https://pagelemon.com/docs/sign-in and https://pagelemon.com/docs/actions explain the blocks in plain words. This page is for AI assistants. Publishing in general: https://pagelemon.com/agents.

Every Page Lemon site is built from eight blocks. A website, an app or an internal tool is a mix of them, not a separate product: pick the blocks from what the person needs. This page maps each block to the tools that exist today; call `get_capabilities` first when unsure what this connection can do.

## The eight blocks

| Block | What it is | Tools today | Guide |
|---|---|---|---|
| **Pages** | What people see: files, versions, previews, Staging, domains, the site check | `publish_site`, `publish_file`, `get_site`, `get_site_versions`, `restore_version`, `create_upload_link`, `check_site`, `add_domain`, `remove_domain` | /agents/publish, /agents/edit, /agents/staging, /agents/domains, /agents/site-check |
| **Lists** | What the site keeps: records with fields; form replies are a list | `get_lists`, `save_list`, `delete_list`, `add_list_items`, `update_list_items`, `remove_list_items`, `import_list_items`, `undo_list_change`, `get_person_records` | /agents/lists, /agents/forms |
| **Sign-in** | Who comes in: visitors (no sign-in, or a passcode), users (the site's customers or members), team (the people who work on the site) | `get_sign_in`, `get_users`, `invite_users`, `remove_users`, `save_group`, `get_teammates`, `invite_teammates`, `remove_teammates`, `save_team_group` | /agents/protect, /agents/member-app, /agents/co-editing, /agents/workspaces |
| **Rules** | Who sees and changes what: site access and each list's rules | `save_site_access`, `save_list` `rules`, `preview_as` | this page, /agents/protect |
| **Views** | How records show on a page | `data-pl-list` and `data-pl-field` markup in the published files; the `views` section of the spec | /agents/lists |
| **Bookings** | Services people book, with times, staff or rooms | `save_service`, `get_bookings`, `get_booking_times`, `add_booking`, `update_booking` | /agents/booking |
| **Payments** | Products, orders and refunds | `save_product`, `get_orders`, `update_order_status`, `refund_order` | /agents/payments |
| **Automations** | What happens next: emails and other steps on an event | `email_users`, `get_automation_runs`, `test_automation`, and the `automations` section of the spec | /agents/notifications, /agents/forms |

Also served: `get_account` (notices first), `get_site`, `save_site_settings`, `delete_site`, `get_site_spec` and `save_site_spec`, `export_site_data`, `get_analytics`, `get_activity_log`, `transfer_site`, `cancel_transfer`, `move_sites`, `bring_back_sites`, `leave_workspace`.
A tool that changes something others can see, or removes something, answers with a `confirm_token` and a description of the change first: show it, and call again with the token only after the person's clear yes.
Limits depend on the plan: they are on https://pagelemon.com/pricing and in each reply; never type a plan number.
Test any of it before launch, as each kind of person, on the staging copy: https://pagelemon.com/agents/testing.

## The two questions

Ask the person both, in one message, before building anything with records:

1. **Who comes in?** Anyone (visitors), the person's customers or members (users), or the person's own team.
2. **What do they keep, and who sees what?** Which records the site holds, who adds them, and whether each person sees everything, only their own, or their group's.

The answers pick the blocks:

- Visitors only, the owner updates the content → a website: Pages, plus Lists if asked.
- Visitors send something in → a form list: Lists with an add-only rule for visitors; replies stay private to the owner and the people they allow.
- Everyone signed in sees the same pages → `save_site_access` with users: Sign-in without per-user records.
- Users each keep their own records → an app: Sign-in, a list whose rules show each user their own rows.
- The team works on shared records by role → an internal tool: team sign-in, lists with team rules (/agents/internal-tools). Five working samples to copy from: /ideas/quota/, /ideas/staffroom/, /ideas/shortlist/, /ideas/masthead/, /ideas/workbench/ (and /ideas/loyalty/ for a loyalty card).
- People book a time → Bookings. People buy → Payments.

## Rules

Rules live in two places: the site's access (`save_site_access`: passcode, users, team or open) and each list's `rules` (`save_list`). `rules` merge into the current rules and a key set to `null` removes it; `fields` replace the whole set. Read the current ones with `get_lists` before changing them.
Never widen who sees records without the person's yes; the tools ask for one where a change lets more people read.
`preview_as` shows what a given kind of person sees: use it before telling the person a rule works.

## The site as one spec

`get_site_spec` returns the whole setup as one document (`docs/contract/site-spec.md` in the API contract): languages, lists, access, sign-in, bookings, payments, views and automations. `save_site_spec` with `dry_run` returns the change and a `confirm_token`; apply after the person's yes. Use it for several blocks at once; use the single tools for one change.

## Worked example: a website

A café: a public menu the owner updates, a contact form, and table bookings.

1. **Pages:** `publish_site` the files.
2. **Lists:** `save_list` `{site, list: "menu", fields: [{name: "name", type: "text"}, {name: "price", type: "money"}]}`, then `add_list_items`.
3. **Views:** `get_lists` returns the `markup` for the list; put it in the page: `<ul data-pl-list="menu"><li><span data-pl-field="name"></span> <span data-pl-field="price"></span></li></ul>`; `publish_site` with `patch`.
4. **Lists and Rules:** a contact form is a list with visitors allowed to add and nothing else (`save_list` `rules`).
5. **Bookings:** `save_service` `haircut`-style: name, length, hours.
6. **Automations:** email the owner on each reply (`save_site_spec` `automations`), then `test_automation`.

## Worked example: an app

A coach's clients sign in, log sessions, and see the coach's replies.

1. **Pages:** `publish_site` the public page and the app pages.
2. **Sign-in:** `save_site_access` for users, then `invite_users`.
3. **Lists and Rules:** `save_list` `sessions` with `rules` so each user sees their own rows.
4. **Views:** markup from `get_lists`; the signed-in page shows only that user's rows.
5. **Payments:** `save_product` for a paid plan or package.
6. **Test:** `preview_as` a user, then tell the person the result.

## Worked example: an internal tool

A team's time-off requests: each person sees their own, their manager approves.

1. **Sign-in:** the team signs in (`save_site_access` with team; `invite_teammates`).
2. **Lists and Rules:** `save_list` `time-off` with person, approver, dates and a status, and `rules` so each person sees their own and the approver edits.
3. **Automations:** email the approver on a new request.
4. **Test** with sample records (`add_list_items`), then ask whether to keep them.

## Links

- The people's pages: https://pagelemon.com/docs/pages, https://pagelemon.com/docs/lists, https://pagelemon.com/docs/sign-in, https://pagelemon.com/docs/actions
- The block guides: https://pagelemon.com/agents/lists, https://pagelemon.com/agents/member-app, https://pagelemon.com/agents/protect, https://pagelemon.com/agents/forms, https://pagelemon.com/agents/booking, https://pagelemon.com/agents/payments, https://pagelemon.com/agents/native-apps
- MCP and REST: https://pagelemon.com/docs/mcp, https://pagelemon.com/docs/api
- The main guide: https://pagelemon.com/agents
