Source: https://boring-cloud.app/docs/overview.md # Boring Cloud documentation Boring Cloud runs small private web apps written by AI agents. You describe a tool, an agent writes it and deploys it, and your colleagues open it at a stable private URL after signing in. This documentation is written for AI agents first. Each page stands on its own, states rules as facts, and gives code that runs as it is. ## Read it as text | Address | Content | | ---------------------------------- | ---------------------------------------------------- | | [`/llms.txt`](https://boring-cloud.app/llms.txt) | list of pages with one line each | | [`/llms-full.txt`](https://boring-cloud.app/llms-full.txt) | every page in one file | | `/docs/.md` | one page as Markdown, for example `/docs/backend.md` | ## What an app is | Part | What it is | Required | | -------- | -------------------------------------------------------------------------- | -------- | | Manifest | a small JSON description, [`boringcloud.json`](https://boring-cloud.app/docs/manifest.md) | yes | | Frontend | static files with an `index.html`, see [Frontend](https://boring-cloud.app/docs/frontend.md) | yes | | Backend | one JavaScript module that answers `/api/*`, see [Backend](https://boring-cloud.app/docs/backend.md) | no | | Database | one private SQL database, see [Database](https://boring-cloud.app/docs/database.md) | no | | Files | private file storage, see [Files](https://boring-cloud.app/docs/files.md) | no | The platform provides everything around it. **Never build these yourself:** - sign-in, sessions, passwords and user accounts; - the URL, the certificate and the hosting; - who can open the app; - API keys: the platform adds them to calls, the app never holds one. ## Choose your way to build | You are | Start with | | ----------------------------------------------------------------------- | ---------------------------------------------------- | | an assistant without a terminal, such as ChatGPT or Claude in a browser | [Build from a chat](https://boring-cloud.app/docs/build-from-chat.md) | | a coding agent with a terminal, such as Claude Code, Codex or Cursor | [Quickstart with a terminal](https://boring-cloud.app/docs/quickstart.md) | | a script or a CI job | [REST API](https://boring-cloud.app/docs/rest-api.md) or the [CLI](https://boring-cloud.app/docs/cli.md) | Both ways produce the same kind of app and use the same permissions. An app started from a chat can be continued from a terminal. ## Rules for an agent, in order 1. Read the workspace guide first: `get_guide` over MCP, or `boringcloud guide`. It contains what this company approved: frameworks, database, files, external APIs, brand and house rules. **When the guide and this documentation differ on a choice, follow the guide.** 2. Make the smallest app that does the job. Leave out the backend when nothing has to be saved or fetched. 3. Write code that follows [Secure code](https://boring-cloud.app/docs/secure-code.md). 4. Deploy. The app is private to the person who asked for it. 5. Give the person the URL. Share the app only when they ask, and only with the people they name. ## What you cannot build here - Public websites, or apps for people outside the workspace. - Apps that need WebSockets, streaming, or a process that runs for hours. Jobs and schedules are fine: see [Platform services](https://boring-cloud.app/docs/platform-services.md). - Backends in another language than JavaScript or TypeScript compiled to JavaScript. - Apps that hold sensitive or regulated data. Boring Cloud is in private beta and has no certification. If a request needs one of these, say so before writing code. See [Limits](https://boring-cloud.app/docs/limits.md). ## Words used here | Word | Meaning | | --------- | ------------------------------------------------------------------------------------------ | | Workspace | a company or a team: its people, apps, stack and approved APIs | | App | one tool with one URL. It keeps its URL, data and access across releases | | Release | one uploaded version of the code, also called a deployment. It never changes once uploaded | | Manager | a person who can deploy, share and roll back an app. The creator is one | | Viewer | a person who can open and use an app | | IT access | the right to decide the stack, the brand and the APIs of a workspace | | Console | `https://console.boring-cloud.app`, where people sign in and manage all of this | --- Source: https://boring-cloud.app/docs/build-from-chat.md # Build from a chat An assistant without a terminal can create, deploy and update complete apps: frontend, backend, database, files and external APIs. It writes plain files and sends them as text with one tool call. ## Before you start The person connects the assistant once, with the address `https://console.boring-cloud.app/mcp`. See [Connect an agent](https://boring-cloud.app/docs/connect.md). If you can see a tool named `deploy_app`, this is done. ## Steps ### 1. Read the guide Call `get_guide` without arguments. It returns what this workspace approved. Follow it. If it names a framework that needs a build you cannot run, use plain HTML, CSS and JavaScript, and tell the person. ### 2. Agree on what to build Ask only what you cannot decide alone. Usually these are: what is saved, who can change it, and whether an external service is needed. ### 3. Create the app Call `create_app`: ```json { "name": "Supply requests", "description": "Ask for office supplies and follow the answer" } ``` Keep the `id` and the `url` from the answer. The URL serves nothing until the first release. ### 4. Write the files Without a build step, write: - `index.html`, with `` and ``. Inline scripts do not run. - `app.js` and `style.css`. - One backend module if something is saved or fetched. It cannot import packages. Start from the template in [Backend](https://boring-cloud.app/docs/backend.md). [Complete example](https://boring-cloud.app/docs/example.md) has all the files of a working app. ### 5. Deploy Call `deploy_app` with every file as `text`: ```json { "appId": "the id from create_app", "manifest": { "schemaVersion": 1, "name": "Supply requests", "runtime": "worker-js", "entry": "dist/worker.mjs", "assets": "dist/client", "database": true }, "worker": { "path": "worker.mjs", "text": "export default { async fetch(request, env) { … } };" }, "assets": [ { "path": "index.html", "text": "…" }, { "path": "app.js", "text": "…" }, { "path": "style.css", "text": "…" } ] } ``` - `entry` and `assets` in the manifest are always these two values here. They describe a project folder, which you do not have, but they are required. - Asset paths are relative to the site root: `index.html`, not `dist/client/index.html`. - Without a backend, leave out `entry` and `worker`, and set `"database": false`. - Binary files such as a PNG go in `contentBase64` instead of `text`. - The whole call can be at most 1 MiB. Check `status` in the answer. `published` means the app is live. On an error, read `details`, fix the files and call again. See [Errors](https://boring-cloud.app/docs/errors.md). ### 6. Give the URL Give the `url` to the person. They sign in and use the app. You cannot open it yourself: there is no access for agents. Ask them what they see. ## Change the app later - Call `deploy_app` again with the same `appId`. The URL, the data and the access stay. - **Send every file each time.** A release replaces the whole code. A file you leave out is gone. - The tools do not return the code of a release. Keep the files in the conversation, or ask the person for them. A manager can download a release with the [REST API](https://boring-cloud.app/docs/rest-api.md). - If a release is broken, call `list_deployments`, then `rollback_app` with the last one that worked. ## When to move to a terminal Use a [coding agent with a terminal](https://boring-cloud.app/docs/quickstart.md) when the app needs npm packages, a framework such as React, more than 1 MiB, or many files. The app keeps its id, URL and data. --- Source: https://boring-cloud.app/docs/quickstart.md # Quickstart with a terminal For coding agents that can run commands. Without a terminal, see [Build from a chat](https://boring-cloud.app/docs/build-from-chat.md). Boring Cloud runs the small internal apps your coding agent builds: a static frontend, an optional Worker backend and an optional private SQL database, behind sign-in, with a stable private URL you can share. This guide takes you from nothing to a deployed, shared app. ## 1. Get an account and a workspace The beta is invitation-only. Open the invitation email from your workspace admin, create your account with the invited address, confirm your email, and accept the invitation. ## 2. Create an agent token In the console: **Agent setup → Create token** (or **Settings → Agent tokens**). Choose the scopes your agent needs: | Scope | Allows | | ------------------ | --------------------------------------------- | | `apps:read` | list apps, read metadata and URLs | | `apps:create` | create apps | | `apps:deploy` | upload releases and roll back apps you manage | | `apps:share` | grant/revoke access to apps you manage | | `deployments:read` | read deployment history and status | A token can never do more than you can: its effective permissions are its scopes intersected with your current access. It is shown once — store it in your agent's environment as `BORINGCLOUD_TOKEN`, never in git. ## 3. Install the CLI and sign in Open **Agent setup** in the console, choose **Copy command**, and run it in a terminal (Node.js 22.12 or later): ```bash npx -y https://console.boring-cloud.app/cli/.tgz setup --url https://console.boring-cloud.app ``` It asks for your token (it stays hidden), signs you in and installs the `boringcloud` command. The CLI comes from your own console, so its version always matches. Check with `boringcloud whoami`. ## 4. Build an app ```bash boringcloud guide # the stack and external APIs approved by your IT team boringcloud init --template team-tracker sprint-tracker cd sprint-tracker npm install && npm run build # → dist/client/ and dist/worker.mjs boringcloud pack --dir . # validates without deploying ``` Or give your agent the instructions from **Agent setup → Copy instructions** and a request such as: > Build a shared sprint tracker for my team, with title, owner, status and due date. Persist entries, make it responsive, deploy privately on Boring Cloud and return the URL. ## 5. Deploy ```bash boringcloud apps create --name "Sprint Tracker" --json # note the id boringcloud deploy --app --dir . ``` The output gives the private URL. Open it: you are asked to sign in to the console, then you land in the app. ## 6. Share, update, roll back ```bash boringcloud share --app --email lea@company.com --role viewer boringcloud share --app --workspace # everyone in the workspace, as viewers npm run build && boringcloud deploy --app # same URL, new version, data kept boringcloud deployments list --app boringcloud rollback --app --to # code/assets only; data is not rewound ``` Owners and admins can disable or archive an app from its **Settings** tab; access stops on the next request. ## Next - [Manifest](https://boring-cloud.app/docs/manifest.md), [Backend](https://boring-cloud.app/docs/backend.md) and [Frontend](https://boring-cloud.app/docs/frontend.md): the rules your code must follow. - [Secure code](https://boring-cloud.app/docs/secure-code.md): what to check before you deploy. - [CLI](https://boring-cloud.app/docs/cli.md): every command, option and exit code. ## For IT People with IT access choose the stack agents must follow and add the external APIs that apps may use. Keys stay with IT: apps use an API without ever seeing its key. Both are in the console under **IT**. See [For IT teams](https://boring-cloud.app/docs/it.md). --- Source: https://boring-cloud.app/docs/connect.md # Connect an agent The address is the same for every assistant: ``` https://console.boring-cloud.app/mcp ``` It is a remote MCP server (Streamable HTTP). The assistant opens a Boring Cloud page where the person signs in, chooses the workspace and the permissions, and allows access. There is no token to copy. The console shows this address under **Agent setup**, with a button for the assistants that can be filled in by a link. ## By assistant | Assistant | How | | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | Claude (web and desktop) | **Agent setup → Add to Claude**, or Claude's settings → Connectors → add a custom connector, and paste the address | | ChatGPT | turn on Developer mode in ChatGPT's settings, then add an MCP server with the address. Depends on the plan and on its admins | | GitHub Copilot in VS Code | **Agent setup → Add to VS Code** | | Cursor | **Agent setup → Add to Cursor** | | Claude Code | `claude mcp add --transport http boringcloud https://console.boring-cloud.app/mcp`, then `/mcp` to sign in | | Codex | `codex mcp add boringcloud --url https://console.boring-cloud.app/mcp` | | Any other MCP client | add a remote or HTTP server with the address and OAuth sign-in | VS Code, in `.vscode/mcp.json`: ```json { "servers": { "boringcloud": { "type": "http", "url": "https://console.boring-cloud.app/mcp" } } } ``` Cursor, in `.cursor/mcp.json`: ```json { "mcpServers": { "boringcloud": { "url": "https://console.boring-cloud.app/mcp" } } } ``` ## What the connection allows - One workspace, and only the permissions ticked on the consent page. - Never more than the person can do. If they lose access to an app or leave the workspace, the agent does too, at once. - 90 days, then the assistant asks to connect again. The person can end it earlier in **Settings → Agent tokens**. - An agent cannot open apps, read their data, invite people, see API keys or change the stack. | Permission | Allows | Tools that need it | | ------------------ | ---------------------------------- | -------------------------------------------------- | | `apps:read` | list apps, read the guide and URLs | `list_apps`, `get_app`, `get_app_url`, `get_guide` | | `apps:create` | create apps | `create_app` | | `apps:deploy` | upload releases, roll back | `deploy_app`, `rollback_app` | | `apps:share` | give and remove access | `share_app`, `revoke_app_access` | | `deployments:read` | read the release history | `list_deployments`, `deployment_status` | If a tool answers `FORBIDDEN` and names a missing permission, the person must connect again and tick it. ## With a token For machines without a browser, such as CI. Create the token in **Agent setup** and keep it in an environment variable. Never write it in a file that is committed. Claude Code, in `.mcp.json`: ```json { "mcpServers": { "boringcloud": { "type": "http", "url": "https://console.boring-cloud.app/mcp", "headers": { "Authorization": "Bearer ${BORINGCLOUD_TOKEN}" } } } } ``` Codex, in `~/.codex/config.toml`: ```toml [mcp_servers.boringcloud] url = "https://console.boring-cloud.app/mcp" bearer_token_env_var = "BORINGCLOUD_TOKEN" ``` Clients that only start local servers can run `boringcloud mcp`, which offers the same tools. See [CLI](https://boring-cloud.app/docs/cli.md). ## For client developers OAuth 2.1 authorization code with PKCE (S256 only), public clients, no refresh token. 1. `POST /mcp` without a token answers `401` with `WWW-Authenticate: Bearer … resource_metadata="https://console.boring-cloud.app/.well-known/oauth-protected-resource/mcp"` (RFC 9728). 2. The server metadata is at `/.well-known/oauth-authorization-server` (RFC 8414). 3. Register with `POST /oauth/register` (RFC 7591). Redirect addresses must be `https`, a loopback address with any port, or the scheme of a known editor. 4. Send the person to `/oauth/authorize` with `response_type=code`, `client_id`, `redirect_uri`, `code_challenge`, `code_challenge_method=S256`, `state`, and optionally `scope` and `resource=https://console.boring-cloud.app/mcp`. 5. The answer contains `code`, `state` and `iss` (RFC 9207). Exchange the code within 60 seconds at `POST /oauth/token`. A code works once. Using it twice ends the access it gave. --- Source: https://boring-cloud.app/docs/manifest.md # Manifest `boringcloud.json` describes a release. With the CLI it is a file at the root of the project. With the MCP tool `deploy_app` it is the `manifest` argument. ```json { "schemaVersion": 1, "name": "Sprint Tracker", "description": "Shared sprint tracker for the team", "runtime": "worker-js", "entry": "dist/worker.mjs", "assets": "dist/client", "database": true } ``` | Field | Required | Rules | | --------------- | -------- | ---------------------------------------------------------------------------------------------- | | `schemaVersion` | yes | `1` | | `name` | yes | 1 to 80 characters | | `runtime` | yes | `"worker-js"`, the only value | | `assets` | yes | relative folder with the built frontend. It must contain `index.html` | | `database` | yes | `true` or `false`. `true` gives the app one private SQL database as `env.APP_DB` | | `entry` | no | relative path of the backend bundle, ending in `.js` or `.mjs`. Leave it out without a backend | | `description` | no | at most 280 characters | | `slug` | no | a suggestion: lowercase letters, digits and dashes, 3 to 40 characters | | `contract` | no | `"2026-11"`, the version of the runtime rules | | `capabilities` | no | `["database"]` is the only value, and it requires `"database": true` | | `schedules` | no | up to 10 `{ "cron": "0 7 * * 1-5", "job": "daily-report" }`, UTC, each at most every 15 minutes. Requires `entry`. See [Platform services](https://boring-cloud.app/docs/platform-services.md#schedules) | ## Combinations that are refused - An unknown field. There is no field for secrets, environment variables, routes, domains or network access, because the platform decides all of them. - `"database": true` without `entry`: only a backend can use a database. - `entry` without a backend file, or a backend file without `entry`. - `"database": true` on a new app when IT turned databases off. Apps that already have one keep it. ## Smallest manifest A tool that only computes in the browser: ```json { "schemaVersion": 1, "name": "VAT calculator", "runtime": "worker-js", "assets": "dist/client", "database": false } ``` --- Source: https://boring-cloud.app/docs/backend.md # Backend The backend is one JavaScript ES module whose default export has a `fetch` method. It runs on Cloudflare Workers, isolated from every other app. ## Template without dependencies Copy this when you have no build step. It is complete and can be deployed as it is. ```js const json = (data, status = 200) => Response.json(data, { status }); const getUser = (request) => ({ id: request.headers.get("x-boringcloud-user-id"), name: decodeURIComponent(request.headers.get("x-boringcloud-user-name") ?? ""), role: request.headers.get("x-boringcloud-role"), // "manager" or "viewer" kind: request.headers.get("x-boringcloud-user-kind") ?? "member", // "member" or "guest" }); export default { async fetch(request, env) { const url = new URL(request.url); if (url.pathname === "/__boringcloud/health") return json({ ok: true }); const user = getUser(request); if (!user.id) return json({ error: "Sign in first." }, 401); try { if (url.pathname === "/api/me" && request.method === "GET") return json({ name: user.name, role: user.role }); return json({ error: "Not found." }, 404); } catch (e) { console.error(e instanceof Error ? e.message : e); return json({ error: "Something went wrong." }, 500); } }, }; ``` ## Template with a build step Starters made by `boringcloud init` contain `src/boringcloud.ts`, a small file without dependencies: ```ts import { defineApp, error, json } from "./boringcloud"; export default defineApp(async (request, env, ctx) => { const { pathname } = new URL(request.url); if (pathname === "/api/me") return json({ name: ctx.user.name, role: ctx.user.role }); return error(404, "Not found."); }); ``` | Helper | What it does | | -------------------------------------------- | ----------------------------------------------------------------------- | | `defineApp(handler)` | answers the health check, reads the user, turns an exception into a 500 | | `getContext(request)` | `{ appId, requestId, user: { id, name, role, kind } }` | | `json(data, init)`, `error(status, message)` | build answers. Errors have the form `{ "error": "…" }` | | `readJson(request, maxBytes)` | reads a JSON body, or returns `null` when it is invalid or over 256 KiB | | `callApi(api, path, init)` | calls an [external API](https://boring-cloud.app/docs/external-apis.md) approved by IT | | `files.put`, `get`, `list`, `delete` | private [files](https://boring-cloud.app/docs/files.md) | Bundle everything into one file, for example with `esbuild src/worker.ts --bundle --format=esm --platform=neutral --target=es2022 --outfile=dist/worker.mjs`. ## Which requests arrive - Only paths under `/api/`. All other paths serve the [frontend](https://boring-cloud.app/docs/frontend.md). - Only from people who are signed in and may open the app. The gateway checks this on every request, before your code runs. - `POST`, `PUT`, `PATCH` and `DELETE` only from the app's own pages. Other sites are refused, so you need no CSRF token. - One exception: the platform calls `GET /__boringcloud/health` on each new release, without a user. Any answer below 500 passes. Code that throws at the top level of the module makes the deployment fail. ## The signed-in user The gateway sets these headers and removes any copy sent by a browser. They are the only trustworthy source of identity. | Header | Value | | -------------------------- | ---------------------------------------------------------------- | | `x-boringcloud-user-id` | stable id of the person in this app. Another app sees another id | | `x-boringcloud-user-name` | display name, URI-encoded: use `decodeURIComponent` | | `x-boringcloud-role` | `manager` or `viewer` | | `x-boringcloud-user-kind` | `member` of the workspace, or `guest` invited from outside | | `x-boringcloud-app-id` | id of the app | | `x-boringcloud-request-id` | id to quote when reporting a problem | The email address is not provided. Store the user id as the author of a record, and the name next to it for display. A `guest` is a person from another organization invited to this app only, always as a `viewer` (see [People and access](https://boring-cloud.app/docs/users-and-access.md#people-outside-the-workspace)). Show guests only what they need: hide other people's records, internal notes and member lists unless the app is meant to share them. ```js if (user.kind === "guest") return json({ items: await listItemsOf(user.id) }); ``` ## What the runtime offers - Web standard APIs: `fetch`, `Request`, `Response`, `URL`, `crypto.subtle`, `crypto.randomUUID()`, `TextEncoder`, `Intl`, `FormData`. - `env.APP_DB` when the manifest has `"database": true`. See [Database](https://boring-cloud.app/docs/database.md). `env` contains nothing else. - Outside access to two places only: [approved APIs](https://boring-cloud.app/docs/external-apis.md) and the app's own [files](https://boring-cloud.app/docs/files.md). ## What it refuses | You cannot use | Instead | | ---------------------------------------------------------- | ------------------------------------------------------------------------- | | `fetch` to any other address: answers `403 egress_blocked` | ask IT to approve the API | | Node.js modules such as `fs`, `path`, `http`, `Buffer` | web standard APIs | | `import` of a package at run time | bundle it, or write the few lines you need | | `eval`, `new Function` | ordinary code | | environment variables and secrets | approved APIs, whose key the platform adds | | cookies and the `Authorization` header, both removed | the identity headers above | | WebSockets, streaming from external APIs | load again from the page at an interval | | long work, retries, work at fixed times, email, PDF, AI | the [platform services](https://boring-cloud.app/docs/platform-services.md) | | variables kept in memory between requests | the database. A module can restart at any time, and run in several places | ## Answers - The gateway sets `Cache-Control: private, no-store` and its own security headers. It removes `Set-Cookie`, CORS headers and any `Content-Security-Policy` you set. - Redirects must stay in the app. Others become a `502`. - To offer a download, set `Content-Type` and `Content-Disposition: attachment; filename="report.csv"`. ## Budget per request 50 ms of CPU time and 50 outside calls, where each database query counts as one. Waiting for a database or an API does not use CPU time. Beyond the budget, the request fails, usually with `502`. Use `batch` for several queries, and page through long lists. See [Limits](https://boring-cloud.app/docs/limits.md). --- Source: https://boring-cloud.app/docs/frontend.md # Frontend The frontend is a set of static files with an `index.html` at its root. The platform serves them as they are. It never installs packages or runs a build. ## Template without a build step ```html My app
``` The first stylesheet gives the company's colors. See [Brand](https://boring-cloud.app/docs/brand.md). ## Call the backend Use relative addresses. The session is sent for you. ```js const api = async (path, options = {}) => { const res = await fetch(`/api${path}`, { ...options, headers: options.body ? { "content-type": "application/json" } : {}, }); if (res.status === 401) { location.reload(); // the session ended: the platform asks the person to sign in again return new Promise(() => {}); } const data = await res.json().catch(() => ({})); if (!res.ok) throw new Error(data.error ?? "Something went wrong. Try again."); return data; }; ``` Never store a token or write a login form. Sessions last up to 12 hours. ## Content security policy Every page has this policy. It cannot be changed. ``` default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; connect-src 'self'; media-src 'self'; object-src 'none'; frame-src 'none'; child-src 'none'; worker-src 'none'; frame-ancestors 'none'; form-action 'self'; base-uri 'none'; manifest-src 'self' ``` | What does not work | Do this | | --------------------------------------------------------------- | ---------------------------------------------------------- | | `

Supply requests

Loading…

    ``` ## app.js ```js const form = document.querySelector("#new"); const message = document.querySelector("#message"); const list = document.querySelector("#list"); const LABELS = { open: "Waiting", approved: "Approved", refused: "Refused" }; const api = async (path, method = "GET", body) => { const res = await fetch(`/api${path}`, { method, headers: body ? { "content-type": "application/json" } : {}, body: body ? JSON.stringify(body) : undefined, }); if (res.status === 401) { location.reload(); return new Promise(() => {}); } const data = await res.json().catch(() => ({})); if (!res.ok) throw new Error(data.error ?? "Something went wrong. Try again."); return data; }; const el = (tag, text, className) => { const node = document.createElement(tag); if (text) node.textContent = text; if (className) node.className = className; return node; }; const load = async () => render(await api("/requests")); const run = async (button, action) => { button.disabled = true; try { await action(); await load(); return true; } catch (e) { message.textContent = e.message; return false; } finally { button.disabled = false; } }; const answerButton = (request, status, label) => { const button = el("button", label, "plain"); button.type = "button"; button.setAttribute("aria-label", `${label}: ${request.item}`); button.addEventListener("click", () => run(button, () => api(`/requests/${request.id}`, "PATCH", { status })), ); return button; }; const render = ({ requests, isManager }) => { message.textContent = requests.length ? "" : "No requests yet."; list.replaceChildren( ...requests.map((request) => { const row = el("li"); const text = el("div"); text.append( el("strong", `${request.quantity} × ${request.item}`), el("span", `${request.author}, ${new Date(request.createdAt).toLocaleDateString()}`), ); row.append(text, el("em", LABELS[request.status], request.status)); if (isManager && request.status === "open") row.append(answerButton(request, "approved", "Approve"), answerButton(request, "refused", "Refuse")); return row; }), ); }; form.addEventListener("submit", async (event) => { event.preventDefault(); const { item, quantity } = Object.fromEntries(new FormData(form)); const done = await run(form.querySelector("button"), () => api("/requests", "POST", { item, quantity: Number(quantity) }), ); if (done) form.reset(); }); load().catch((e) => { message.textContent = e.message; }); ``` ## style.css ```css :root { --accent: var(--brand-primary, #1f4fd8); } * { box-sizing: border-box; } body { margin: 0; color: #1c1c1f; font: 16px / 1.5 system-ui, sans-serif; font-family: var(--brand-font-body, system-ui, sans-serif); } main { max-width: 44rem; margin: 0 auto; padding: 2rem 1rem; } h1 { font-family: var(--brand-font-heading, inherit); } form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; } label { display: grid; gap: 0.25rem; font-size: 0.875rem; } label:first-child { flex: 1 1 14rem; } input, button { min-height: 2.5rem; padding: 0 0.75rem; border: 1px solid #85858c; border-radius: 8px; font: inherit; } button { border-color: var(--accent); background: var(--accent); color: #ffffff; cursor: pointer; } button.plain { border-color: #85858c; background: #ffffff; color: #1c1c1f; } button:disabled { opacity: 0.6; } :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; } ul { padding: 0; list-style: none; } li { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; padding: 0.75rem 0; border-top: 1px solid #dcdce0; } li div { display: grid; flex: 1 1 12rem; overflow-wrap: anywhere; } li span { color: #5c5c63; font-size: 0.875rem; } em { font-style: normal; } em.approved { color: #166534; } em.refused { color: #b42318; } ``` ## Larger examples With a terminal, `boringcloud init` copies a project to start from: | Template | Shows | | -------------- | ------------------------------------------------------------------------- | | `team-tracker` | React, TypeScript, Vite, a database with an added column | | `web-research` | plain frontend, TypeScript backend, an external API, files and a database | | `hello-world` | the smallest project with a backend | --- Source: https://boring-cloud.app/docs/platform-services.md # Platform services Beyond its database and files, a backend can use four services that the platform runs for every app. Each one can be turned off by IT, has a daily limit per app, and is reached through an address that exists only for your backend. The workspace guide says which ones are on, with the guidance of IT: **follow the guide when it differs from this page**. Import the helpers from `src/boringcloud.ts`. Without a build, send `POST` with a JSON body to the addresses below. | Service | Helpers | Address | | ----------------- | ------------------------------------------------ | ------------------------------------- | | Background jobs | `jobs.enqueue`, and `schedules` in the manifest | `https://jobs.boringcloud.internal` | | Email | `mail.send` | `https://mail.boringcloud.internal` | | Browser rendering | `browser.pdf`, `browser.screenshot`, `browser.markdown` | `https://browser.boringcloud.internal` | | AI | `ai.text`, `ai.embed`, `ai.toMarkdown` | `https://ai.boringcloud.internal` | A refused call throws `ServiceError`, with `status` and a stable `code`. Catch it and show the person a clear message. ## Which one to use | Need | Use | Not | | ------------------------------------------------------------ | ------------------------------------------------------------- | ----------------------------------------------------------- | | Text of a PDF, Word file, spreadsheet or scan | `ai.toMarkdown` | browser rendering: it renders pages, it does not read files | | Specific fields from a photo, receipt or screenshot | `ai.text` with `image`, asking for JSON, then check the JSON | `ai.toMarkdown`: it describes an image, it does not extract fields reliably | | Summarize, classify or draft text | `ai.text`, on the shortest text that does the job | an external AI API, unless IT approved one for this | | Find similar records, search by meaning | `ai.embed`, with the vectors stored in the database | sending every record to `ai.text` | | A PDF or image of something the app shows | `browser.pdf` or `browser.screenshot` from your own HTML | a PDF library or an AI model | | Readable content of a public web page | `browser.markdown({ url })`, if IT allows addresses | `ai.text` on raw HTML | | Work longer than a second, many items, or that must be retried | `jobs.enqueue`, with the progress saved in the database | a long `/api` request, or a loop in the browser | | Work at fixed times | `schedules` in the manifest | polling from the browser | | Tell someone that something needs them | `mail.send`, and a record in the database that the app shows | an external email API | Prefer no service when plain code does the job: each call takes time and counts against a limit. ## Background jobs ```ts import { defineApp, jobs, JobFailed } from "./boringcloud"; export default defineApp( async (request, env, ctx) => { // In a route: answer at once, let the job do the work. await jobs.enqueue("import-csv", { fileKey: "imports/2026-12.csv", by: ctx.user.id }); return Response.json({ queued: true }, { status: 202 }); }, { jobs: { "import-csv": async (payload, env, job) => { const { fileKey } = payload as { fileKey: string }; if (!fileKey) throw new JobFailed("no file"); // stops without retrying // … read the file, write rows, save the progress in the database }, }, }, ); ``` - `jobs.enqueue(name, payload, { delaySeconds })`: the name has lowercase letters, digits and dashes, starting with a letter, up to 40 characters. The payload is JSON of at most 64 KB. The delay is at most 12 hours. - The job runs within seconds, with up to 30 seconds of CPU time and 200 outside calls. A job that throws is retried after 30 seconds, 2 minutes and 8 minutes: 4 attempts in all. Throw `JobFailed` when trying again cannot help. Write jobs so that running one twice does no harm. - There is no signed-in user in a job. Put the ids it needs in the payload, such as the user id to email when it ends. `job` gives `appId`, `job`, `attempt` and `trigger` (`"app"` or `"schedule"`). - The job arrives at your backend as `POST /__boringcloud/jobs/`, with the payload as body. Only the platform can call this path. Without the helpers, answer `2xx` when done, `4xx` to stop, `5xx` to be retried. - The app needs a backend. Jobs of a rolled-back or disabled app do not run. ### Schedules Declare them in the manifest. They run the job with a `null` payload. ```json "schedules": [{ "cron": "0 7 * * 1-5", "job": "daily-report" }] ``` - Five fields, in UTC: minute, hour, day of the month, month, day of the week. `*`, numbers, ranges `1-5`, lists `1,15` and steps `*/30` work. - At most 10 schedules, each running at most every 15 minutes (96 times a day). A release with schedules is refused when IT turned jobs off. - Rolling back a release rolls back its schedules. ## Email ```ts await mail.send({ to: request.requesterId, subject: "Your request was approved", text: "Open the app to see it." }); ``` - `to` is one or more user ids (`ctx.user.id`, up to 20), never an address. They must be people who can open the app at that moment; otherwise nothing is sent and the call fails with `unknown_recipient`. The app never sees addresses and cannot write to anyone else. - Each person receives their own message, from the platform address, with the app's name in the subject and a footer naming the app. `text` is required, `html` is optional: keep it simple, without scripts or outside images. - The daily limit counts recipients. Record what you send in the database, so people can also see it in the app. ## Browser rendering ```ts const pdf = await browser.pdf({ html: invoiceHtml }, { format: "a4" }); await files.put(`invoices/${id}.pdf`, pdf, "application/pdf"); ``` - `{ html }` is rendered in a real browser with every network request blocked: put the CSS in a `