REST API reference
The Page Lemon REST API lives at https://api.pagelemon.com/v2. Code agents with a shell use it to publish and update sites; AI agents should start with the publishing guide for AIs (Markdown).
Last updated
On this page
Building your own admin or server? See Build your own admin.
The full, machine-readable list of routes is the OpenAPI document the server publishes; this page covers the ones most scripts need.
Quick start
Publish a page without an account (it stays online for 72 hours unless you keep it):
curl -sS https://api.pagelemon.com/v2/anonymous-sites \
-H "Content-Type: application/json" \
-d "{\"files\": [{\"path\": \"index.html\", \"content_base64\": \"$(base64 < index.html | tr -d '\n')\"}]}"With an API key, the site is yours from the start: make the site, upload each file, then publish them as a version (below).
Hosts
| Host | Serves |
|---|---|
https://pagelemon.com | This site, /agents, /llms.txt, /docs/* |
https://api.pagelemon.com | REST API under /v2 |
https://mcp.pagelemon.com/mcp | Remote MCP server (streamable HTTP) |
https://dash.pagelemon.com | Your sites, workspaces, people, keys and billing |
https://<name>.pagelemon.dev | Your sites |
Auth
Send credentials as Authorization: Bearer <token>.
| Credential | Looks like | Where it comes from | What it can do |
|---|---|---|---|
| Site token | pl_sitetoken_… | Returned once when you publish without an account | Publish, upload, list and restore versions of that one site, and end it, until it's kept. After that it only reports the site's state (GET /v2/anonymous-sites/{site}) |
| Claim link | https://dash.pagelemon.com/claim#… | Returned once when you publish without an account | A signed-in person keeps the site in a workspace |
| API key | pl_apikey_… | The Page Lemon app (see API tokens) | What its grants allow: workspaces or single sites, with the scopes read, data, deploy and manage, and people for the People's data tick (see API tokens) |
| Connector token | pl_mcpaccess_… | Issued to an AI app (Claude.ai, ChatGPT, Claude Code…) after you sign in and approve it | MCP only |
We store only hashes of keys, so a lost key can't be shown again. Make a new one instead.
Errors
Errors are problem details (RFC 9457):
{ "type": "https://pagelemon.com/docs/errors/version-conflict", "title": "Someone else changed this first", "status": 409, "detail": "…", "key": "version_conflict", "request_id": "…" }Branch on key, never on title. When key is a general one (conflict, validation_failed), reason names the exact problem, for example 409 conflict with reason: payments_not_connected.
Anything that could overwrite someone's work says the version it is based on: a publish sends base_version, an item or a setting sends the ETag you read as If-Match. None is 428, a stale one is 412 (a site's publish is 409 version_conflict). A 412 carries the current state you may read, so one more call fixes it; a 428 may carry it too (an item's names its version), but when a change asks first, an API key's 428 comes before anything is read and is empty; when it carries nothing, read the thing with its GET and send its ETag. If-Match: * saves over it on purpose. Creating something new needs no version.
| Key | Status | Meaning |
|---|---|---|
validation_failed | 400 | A field or parameter isn't valid |
unauthorized | 401 | Missing or invalid credential |
forbidden | 403 | You don't have the right to do this |
insufficient_scope | 403 | The key doesn't have the scope for this |
plan_limit | 403 | Your plan doesn't include this |
not_found | 404 | No such site, version or file |
precondition_required | 428 | The change named no version: send base_version (a publish) or If-Match (an item or a setting) |
precondition_failed | 412 | The version you sent is out of date: the answer carries the current state |
version_conflict | 409 | base_version isn't the live version |
blob_gone | 409 | An uploaded file is no longer stored: upload it again |
pages_site_expired | 410 | The site wasn't kept and has ended |
too_large | 413 | Over a size limit |
confirmation_required | 422 | Show the person what it will do, then send the same request again with its confirm_token in the Confirm-Token header (never in the body) |
rate_limited | 429 | Too many requests; retry_after_seconds says when to try again |
When a call waits for the person
Some calls from an API key wait for the person who owns it instead of running: the answer is 202 with approval.url (always on dash.pagelemon.com), and nothing happens until they press Approve there within 30 minutes. Poll GET /v2/approvals/{approval} for the result.
- Every save of a site's whole spec (
PUT /v2/sites/{site}/spec) waits, after itsconfirmation_requiredstep; turning sign-in on also asks the person four questions about their users there. - After the key reads text other people wrote (form replies, bookings, orders, a list's items that a visitor, a signed-in user or someone outside your workspace wrote into, users, analytics paths, or the contents of a site file that came in through an upload link, a GitHub deploy or an anonymous publish, with
GET .../versions/{version}/files/{file}), publishing, links handed out and writes to public lists wait for the person for the next 12 hours. Listing a version's files, reading a file you or your teammates published, and reading back items you or your teammates added or edited, does not count. For a script that deploys on its own, use a key that only publishes, and a separate key for reading replies or bookings.
Lists of things come in pages: ?limit (default 50, at most 200) and ?cursor; the answer is {items, next_cursor}, with no next_cursor on the last page. Routes that change things take an Idempotency-Key header, so a retry after a lost reply never does the work twice.
Publish
Without an account
POST /v2/anonymous-sites with {files: [{path, content_base64}]} makes a new site held for 72 hours: at most 100 files and 1 MB in all, with index.html at the root; no hidden, program, server-side or non-media binary files.
Response 201: {site, url, site_token, claim_url, expires_at}. site_token and claim_url are shown only this once.
With the site token: GET /v2/anonymous-sites/{site} says whether the site is live, claimed or expired; DELETE /v2/anonymous-sites/{site} answers confirmation_required; the same DELETE with the confirm_token in the Confirm-Token header ends it now.
With an API key
POST /v2/siteswith{workspace, name, title?}makes a site (nameis its address: 8 to 63 characters ofa-z,0-9and-on Free, 5 to 63 on paid plans).POST /v2/sites/{site}/fileswith{content_base64, content_type?}stores one file (up to 50 MB) and returns{sha256, size}. The same bytes give the same file, so unchanged files need no new upload. For large files,POST /v2/sites/{site}/uploadsgives one-time upload links instead (PUTthe raw file to each).POST /v2/sites/{site}/versionswith{files: [{path, sha256, content_type?}], base_version}publishes them as the next version.
A full publish replaces every file. Patch: add "patch": true to keep the live files, add files and drop the paths in remove. base_version is required: the live version's number you built on (0 for a site with no version yet). Without it you get 428 precondition_required with the live number, and nothing changes. If someone published since, you get 409 version_conflict and nothing changes; the answer lists the versions since and the files that changed (since, changes, paths), and next says what to do. A patch is merged when none of its files changed since its base, otherwise refused with the changed paths; a patch with no files and no remove is 400. Read the site again, apply your change to the live files and send it with the live number; there is no automatic retry.
Response 201: the version {id, number, kind, live, file_count, bytes, redirects, rollback_of, created_at}.
Paths are relative, with no empty, . or .. part and nothing under __pl/. How many new files a site may add a day, and how much it may store, depend on the plan (See pricing).
Sites
{site} in a path is the site's id (site_…, from POST /v2/sites or GET /v2/sites), never its name or address: a name is 404 saying so.
| Method | Path | Notes |
|---|---|---|
| GET | /v2/sites | The sites you reach, in every workspace or one (a key: those its grants read), each with its id |
| POST | /v2/sites | Make a site in a workspace |
| GET | /v2/sites/{site} | Name, title, address and team access |
| PATCH | /v2/sites/{site} | Change the title, or turn team sign-in on or off; needs If-Match (the etag of GET /v2/sites/{site}) |
| DELETE | /v2/sites/{site} | Delete the site and its data; needs If-Match (the site's etag). The first call answers confirmation_required; with an API key, the same call with the confirm_token in the Confirm-Token header answers 202 with approval.url, where the person types the site's address to delete it. A deleted site can be brought back for 30 days |
| GET | /v2/sites/{site}/versions | Every version, newest first |
| GET | /v2/sites/{site}/versions/{version}/files | The files of a version (live for the live one), by path |
| GET | /v2/sites/{site}/versions/{version}/files/{file} | One file ({file} percent-encoded): text as UTF-8, else base64, up to 1 MB |
| POST | /v2/sites/{site}/versions/{version}:restore | Make an earlier version live again, as a new version |
| GET, POST | /v2/sites/{site}/domains | The site's custom domains; {hostname} connects one and lists the DNS records to add. Guide: Connect a domain |
| POST | /v2/sites/{site}/domains/{domain}:verify | Check the records and make the domain live |
| DELETE | /v2/sites/{site}/domains/{domain} | Disconnect a domain; it stays yours at its registrar. Needs If-Match (the domain's etag from GET /v2/sites/{site}/domains) |
Lists
The site's lists, and its form replies and bookings as lists. Same rules as the MCP list tools; the guide for AIs is pagelemon.com/agents/lists.
| Method | Path | Notes |
|---|---|---|
| GET, POST | /v2/sites/{site}/lists | The site's lists; make a list or a form |
| GET, PUT, DELETE | /v2/sites/{site}/lists/{list} | Read a list and its fields; replace its fields or settings; delete it (the first call asks, the same call with the Confirm-Token header deletes). PUT and DELETE need If-Match (the list's etag from the GET) |
| GET, POST | /v2/sites/{site}/lists/{list}/items | The items you can see, newest first; add one with {values: {<field>: value}} (on an app's list, for one user: {values, assigned_user_id}) |
| POST | /v2/sites/{site}/lists/{list}/items:batch-create | Add up to 100 items, all or none |
| POST | /v2/sites/{site}/lists/{list}/items:batch-update | Change up to 100 items, all or none; each item names its id and the version you read, or was with what you read ({"values": {…}}, and owner for the owner's columns) |
| POST | /v2/sites/{site}/lists/{list}/items:batch-delete | Remove up to 100 items (the first call asks, the same call with the Confirm-Token header removes) |
| POST | /v2/sites/{site}/lists/{list}/items:sort | Put the named items in the given order |
| GET, PATCH, DELETE | /v2/sites/{site}/items/{item} | One item; PATCH is a merge patch and DELETE removes it; both need If-Match (the item's ETag, or * to save over it) |
| POST | /v2/sites/{site}/lists/{list}:import | Import from CSV or Excel (the first call previews, the same call with the Confirm-Token header imports) |
| POST | /v2/sites/{site}/lists/{list}:export | The items you can see, as CSV |
| GET | /v2/sites/{site}/lists/{list}/changes | Changes to the items, newest first |
| POST | /v2/sites/{site}/lists/{list}/changes/{change}:undo | Undo one change, if the item still stands as that change left it |
| POST | /v2/sites/{site}/lists:bind | Turn repeated blocks of a page into a list and mark the page up |
A content list whose owner turned on its public JSON is at https://<site address>/_pl/lists/<list>.json (only the chosen fields of items shown on the site).
Account
| Method | Path | Notes |
|---|---|---|
| GET | /v2/me | Your account: email and Page Lemon language |
| GET | /v2/inbox | Form replies, bookings and publishes waiting on you across your sites, newest first |
| GET, POST | /v2/api-keys | Your API keys; make one with {name, grants: [{workspace, site?, scopes}]} |
| DELETE | /v2/api-keys/{api_key} | Revoke a key; it stops working at once |
Keeping sites, accepting invites and billing are handled at dash.pagelemon.com.
Serving on pagelemon.dev
/servesindex.html./aboutservesabout.htmlorabout/index.html.- Missing files get the site's
404.htmlif present, otherwise ours. - Single-page app fallback: a site's own
200.htmlanswers every address that has no file, with status 200. Without one, and without a404.html, a site whose only page isindex.htmlserves it for an address with no file and no extension; a site with other pages answers 404. - Headers:
X-Content-Type-Options: nosniff,Referrer-Policy: strict-origin-when-cross-origin,Cache-Control: public, max-age=60for HTML andmax-age=300for other files. Content types come from an allowlist; unknown types are served asapplication/octet-stream. - Anonymous and Free sites get a small "Live on Page Lemon" badge before
</body>. It's plain HTML and CSS, with no script, and includes a link to report the site. - Expired or deleted sites return
410. Sites taken down for abuse return451.
.pagelemon.json
After publishing, agents write this file in the project folder and add it to .gitignore, so the next session can update the same site:
{ "site": "brave-otter-4821", "url": "https://brave-otter-4821.pagelemon.dev", "version": 1, "site_token": "pl_sitetoken_…" }