# Backend apps ### What a backend app is for 1. **A backend app is an API server.** A backend app (a `@simple_server` server behind root) answers API calls from pages and agents: JSON, files, redirects, webhooks. Browser pages (an HTML UI) live in a frontend app (`https://pam.pilely.app/specs/frontend_apps`), and those pages call the backend. This is a guideline: root does not enforce it, and forwards whatever the backend answers (`### Forwarding to backend apps`). A backend that serves browser pages is outside what the platform supports, and root adds nothing to make it work. On a `public` app such a page may load. On a `protected` or `private` app a browser page load carries no token and gets the uniform `404`: no bootstrap page and no shell ticket stand in front of a backend app. Anything else you build on a backend's pages is at your own risk. 2. **How a frontend app's pages call the backend.** A page calls the backend's host with `fetch`, and root grants it CORS (`### Forwarding to backend apps`, item 7). With no token, the call is the anonymous caller shape (`### Forwarding to backend apps`, item 3): it reaches a `public` app's reads (`GET`, `HEAD`, `OPTIONS`), and anything else only through a `public` public route (items 4 and 5 there). The frontend app's token, sent with `window.pilely.fetch`, is another app's token on the backend's host: root admits it only on a path covered by an `app` public route whose `@simple_group` holds the frontend app as an `app` member (item 5 there), and the backend then receives the person as `user:` on the frontend app (item 3 there). Everywhere else root treats it as no token. **The usual setup:** put the routes the pages call under `/api`, and add one `app` public route at `/api` with `methods: ["GET", "POST"]` whose `@simple_group` holds the frontend app as an `app` member (`https://pilely.app/README.md` → `### POST /~/apps/{pile_id}/public_routes/add`). A sender with no token, such as a webhook, gets its own `public` public route. ### Forwarding to backend apps 1. **Root forwards every request unchanged.** On a backend app's host (`