Docs

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

Page options
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):

bash
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

HostServes
https://pagelemon.comThis site, /agents, /llms.txt, /docs/*
https://api.pagelemon.comREST API under /v2
https://mcp.pagelemon.com/mcpRemote MCP server (streamable HTTP)
https://dash.pagelemon.comYour sites, workspaces, people, keys and billing
https://<name>.pagelemon.devYour sites

Auth

Send credentials as Authorization: Bearer <token>.

CredentialLooks likeWhere it comes fromWhat it can do
Site tokenpl_sitetoken_…Returned once when you publish without an accountPublish, 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 linkhttps://dash.pagelemon.com/claim#…Returned once when you publish without an accountA signed-in person keeps the site in a workspace
API keypl_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 tokenpl_mcpaccess_…Issued to an AI app (Claude.ai, ChatGPT, Claude Code…) after you sign in and approve itMCP 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):

json
{ "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.

KeyStatusMeaning
validation_failed400A field or parameter isn't valid
unauthorized401Missing or invalid credential
forbidden403You don't have the right to do this
insufficient_scope403The key doesn't have the scope for this
plan_limit403Your plan doesn't include this
not_found404No such site, version or file
precondition_required428The change named no version: send base_version (a publish) or If-Match (an item or a setting)
precondition_failed412The version you sent is out of date: the answer carries the current state
version_conflict409base_version isn't the live version
blob_gone409An uploaded file is no longer stored: upload it again
pages_site_expired410The site wasn't kept and has ended
too_large413Over a size limit
confirmation_required422Show 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_limited429Too 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 its confirmation_required step; 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

  1. POST /v2/sites with {workspace, name, title?} makes a site (name is its address: 8 to 63 characters of a-z, 0-9 and - on Free, 5 to 63 on paid plans).
  2. POST /v2/sites/{site}/files with {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}/uploads gives one-time upload links instead (PUT the raw file to each).
  3. POST /v2/sites/{site}/versions with {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.

MethodPathNotes
GET/v2/sitesThe sites you reach, in every workspace or one (a key: those its grants read), each with its id
POST/v2/sitesMake 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}/versionsEvery version, newest first
GET/v2/sites/{site}/versions/{version}/filesThe 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}:restoreMake an earlier version live again, as a new version
GET, POST/v2/sites/{site}/domainsThe site's custom domains; {hostname} connects one and lists the DNS records to add. Guide: Connect a domain
POST/v2/sites/{site}/domains/{domain}:verifyCheck 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.

MethodPathNotes
GET, POST/v2/sites/{site}/listsThe 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}/itemsThe 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-createAdd up to 100 items, all or none
POST/v2/sites/{site}/lists/{list}/items:batch-updateChange 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-deleteRemove up to 100 items (the first call asks, the same call with the Confirm-Token header removes)
POST/v2/sites/{site}/lists/{list}/items:sortPut 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}:importImport from CSV or Excel (the first call previews, the same call with the Confirm-Token header imports)
POST/v2/sites/{site}/lists/{list}:exportThe items you can see, as CSV
GET/v2/sites/{site}/lists/{list}/changesChanges to the items, newest first
POST/v2/sites/{site}/lists/{list}/changes/{change}:undoUndo one change, if the item still stands as that change left it
POST/v2/sites/{site}/lists:bindTurn 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

MethodPathNotes
GET/v2/meYour account: email and Page Lemon language
GET/v2/inboxForm replies, bookings and publishes waiting on you across your sites, newest first
GET, POST/v2/api-keysYour 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

  • / serves index.html. /about serves about.html or about/index.html.
  • Missing files get the site's 404.html if present, otherwise ours.
  • Single-page app fallback: a site's own 200.html answers every address that has no file, with status 200. Without one, and without a 404.html, a site whose only page is index.html serves 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=60 for HTML and max-age=300 for other files. Content types come from an allowlist; unknown types are served as application/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 return 451.

.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:

json
{ "site": "brave-otter-4821", "url": "https://brave-otter-4821.pagelemon.dev", "version": 1, "site_token": "pl_sitetoken_…" }

Still stuck? Ask your AI

Need support with PageLemon.com, about REST API reference

Still need a person? Contact us