# REST API

Base: `https://console.boring-cloud.app/api/v1`. Authentication: console session cookie (browser; unsafe methods require same-origin `Origin`) or `Authorization: Bearer ssc_pat_…` (agents). JSON in/out. Every response carries `x-request-id`.

Errors: `{"error": {"code", "message", "requestId", "details?"}}` with codes `UNAUTHENTICATED 401`, `FORBIDDEN 403`, `NOT_FOUND 404` (also used for resources you cannot see), `CONFLICT 409`, `PAYLOAD_TOO_LARGE 413`, `VALIDATION_FAILED 422`, `QUOTA_EXCEEDED 429`, `RATE_LIMITED 429`, `INTERNAL 500`, `DEPLOYMENT_FAILED 502`, `RUNTIME_UNAVAILABLE 503`. What to do about each one: [Errors](https://boring-cloud.app/docs/errors.md).

| Method & path                                                                            | Auth                    | Scope                       | Notes                                                                                                     |
| ---------------------------------------------------------------------------------------- | ----------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------- |
| `GET /health`                                                                            | –                       | –                           | liveness                                                                                                  |
| `GET /runtime-contract`                                                                  | –                       | –                           | manifest rules, limits, workflow                                                                          |
| `GET /me`                                                                                | any                     | –                           | user, workspaces (token: its workspace), runtime                                                          |
| `GET /workspaces` · `POST /workspaces`                                                   | any · session           | –                           | create: dev or bootstrap admins                                                                           |
| `GET /workspaces/:id/members`                                                            | member                  | –                           |                                                                                                           |
| `PATCH /workspaces/:id/members/:userId`                                                  | session, owner          | –                           | `{role?, itAccess?}`; last owner protected                                                                |
| `DELETE /workspaces/:id/members/:userId`                                                 | session                 | –                           | owner: anyone; admin: members; self: leave                                                                |
| `GET/POST /workspaces/:id/invitations` · `DELETE …/:invId`                               | session, admin          | –                           | `{email, role, itAccess?}`; only owners invite admins or give IT access                                   |
| `GET /invitations/:id` · `POST /invitations/:id/accept`                                  | session (invited email) | –                           | single use                                                                                                |
| `GET /workspaces/:id/tokens` · `POST /tokens` · `DELETE /workspaces/:id/tokens/:tokenId` | session                 | –                           | `{workspaceId, name, scopes[], expiresInDays ≤ 90}`; raw token returned once                              |
| `GET /workspaces/:id/activity?appId=&limit=`                                             | session                 | –                           | admins: all; members: own + managed apps                                                                  |
| `GET /workspaces/:id/apps`                                                               | any                     | `apps:read`                 | visible apps only                                                                                         |
| `POST /apps`                                                                             | any                     | `apps:create`               | `{workspaceId, name, description?, slug?}`                                                                |
| `GET /apps/:id` · `PATCH /apps/:id`                                                      | any                     | `apps:read` · `apps:deploy` |                                                                                                           |
| `POST /apps/:id/status`                                                                  | session                 | –                           | `{status}` = active, disabled or archived (manager or admin)                                              |
| `DELETE /apps/:id`                                                                       | session                 | –                           | `{confirmName}`: an archived app, owner or admin. Deletes its data for good                               |
| `POST /apps/:id/owner`                                                                   | session                 | –                           | `{userId}` (owner or admin)                                                                               |
| `GET /apps/:id/access`                                                                   | any                     | `apps:read`                 | managers/admins                                                                                           |
| `POST /apps/:id/access`                                                                  | any                     | `apps:share`                | `{target:"user", email, role}` or `{target:"workspace"}`                                                  |
| `POST /apps/:id/access/revoke`                                                           | any                     | `apps:share`                | `{target:"user", userId}` or `{target:"workspace"}`                                                       |
| `GET /apps/:id/usage`                                                                    | any                     | –                           | managers/admins; 14 days                                                                                  |
| `GET /apps/:id/deployments` · `GET …/:depId`                                             | any                     | `deployments:read`          |                                                                                                           |
| `POST /apps/:id/deployments`                                                             | any                     | `apps:deploy`               | artifact JSON, see below, `Idempotency-Key` header, ≤ 15 MiB; `201 {deployment, published, url, message}` |
| `GET /apps/:id/deployments/:depId/artifact`                                              | any                     | `deployments:read`          | original artifact                                                                                         |
| `POST /apps/:id/rollback`                                                                | any                     | `apps:deploy`               | `{deploymentId}`; code/assets only                                                                        |
| `POST /apps/:id/deployments/prune`                                                       | any                     | `apps:deploy`               | `{keep}`                                                                                                  |

## Stack, APIs and instructions for agents

| Method & path                               | Auth                | Scope       | Notes                                                                         |
| ------------------------------------------- | ------------------- | ----------- | ----------------------------------------------------------------------------- |
| `GET /workspaces/:id/guide`                 | member              | `apps:read` | `{markdown, stack, apis}`: what an agent must follow                          |
| `GET /workspaces/:id/apis`                  | member              | `apps:read` | approved APIs, never a key                                                    |
| `GET /apps/:id/apis`                        | app manager, admin  | `apps:read` | APIs this app can call, and its calls today                                   |
| `GET/PUT /workspaces/:id/it/stack`          | session + IT access | –           | `{config, baseVersion, logo?}`; saving approves; `409` if someone saved first |
| `GET/POST /workspaces/:id/it/apis`          | session + IT access | –           | `secret: {value, username?}` is write-only                                    |
| `PUT/DELETE /workspaces/:id/it/apis/:apiId` | session + IT access | –           | `secret: null` keeps the key, unless the address or method of auth changed    |
| `POST /workspaces/:id/it/apis/:apiId/test`  | session + IT access | –           | `{method, path, body?}`: one real call with the stored key                    |

IT access is a separate grant (`itAccess` in `/me`), never implied by a role. Agent tokens are refused on every `/it/` path.

Other endpoints: `GET /launch/:appId?next=` (console session → single-use ticket → app host), `/api/auth/*` (Better Auth: sign-up/in/out, verify-email, password reset, sessions — allow-listed), `/mcp` (MCP Streamable HTTP, bearer only, see [MCP tools](https://boring-cloud.app/docs/mcp.md)), `/oauth/register`, `/oauth/authorize`, `/oauth/token` and `/.well-known/oauth-*` (sign-in of assistants), `GET/POST /api/v1/connect` (its consent page, console session only), `GET /api/v1/workspaces/:id/brand/logo`.

App hosts (`https://<label>.<apps-domain>`): `/_boringcloud/launch?ticket=` (consumes ticket), `POST /_boringcloud/logout`, `/api/*` → app backend, everything else → assets.

## Deploy without the CLI

`POST /apps/:id/deployments` takes the whole release in one JSON body:

```json
{
  "manifest": {
    "schemaVersion": 1,
    "name": "…",
    "runtime": "worker-js",
    "entry": "dist/worker.mjs",
    "assets": "dist/client",
    "database": true
  },
  "worker": { "path": "worker.mjs", "size": 4641, "sha256": "<hex>", "contentBase64": "<…>" },
  "assets": [{ "path": "index.html", "size": 460, "sha256": "<hex>", "contentBase64": "<…>" }]
}
```

`size` and `sha256` describe the decoded bytes and are both checked. Send an `Idempotency-Key` header (8 to 100 characters) so that a retry after a network error never creates a second release. `boringcloud pack --out release.json` writes this body for you.

```bash
curl -sS -X POST "https://console.boring-cloud.app/api/v1/apps/$APP_ID/deployments" \
  -H "Authorization: Bearer $BORINGCLOUD_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ci-$COMMIT_SHA" \
  --data-binary @release.json
```

The call answers when the release is live or has failed. See [Releases](https://boring-cloud.app/docs/releases.md).
