This page documents
@squarecloud/api v6, a rewrite of the SDK. Coming from v5? Read the v5 → v6 migration guide.Requirements
- Node.js 22 or newer, Deno, Bun or an edge runtime. The SDK only needs
fetch,FormData,Bloband web streams. - An API key (see API key and scopes).
@squarecloud/api-types.
Installation
- npm
- pnpm
- yarn
- bun
- deno
API key and scopes
Create a key at squarecloud.app/account/security. The SDK sends it as-is in theAuthorization header (no Bearer prefix).
A key can be limited to scopes (apps:read, apps:deploy, apps:control, ai:chat, …) and to specific apps or databases:
- A call outside those limits throws a
SquareCloudAPIErrorwith 403MISSING_SCOPEorRESOURCE_NOT_ALLOWED. - List methods (
account.me(),apps.statusAll(), …) only return the resources the key can see. - An unknown, revoked or expired key is 401
ACCESS_DENIED.
SQUARECLOUD_API_KEY environment variable. Set it in the terminal where you run them:
- macOS / Linux
- Windows (PowerShell)
Creating the client
- TypeScript / ESM
- CommonJS
TypeError in the constructor, before any request.
Options
Modules
The only runtime exports are
SquareCloudAPI, SquareCloudAPIError and BASE_URL. Every other export (App, RuntimeStats, ErrorCode, …) is a type:
Conventions
Ids first, plain data back
Every method takes the resource id as its first argument and returns plain data (no classes, no cache). Field names are the API’s own (created_at, version_id, lastModified, joinedAt, netIO, …), so the API reference applies as-is.
- Mutations resolve to
void, unless the API returns data (envs.*,deploys.setWebhook,deploys.linkGithubApp,databases.resetCredentialsand thecreatemethods). - A string result is never
undefined: it is""when the API sends none. - Lists come complete in one call: there is no pagination.
Workspace apps
EveryappId also accepts the composite form <appId>-<workspaceId> to act on an app shared with you through a workspace. workspaces.get() and workspaces.list() return raw ids; you build the composite id yourself:
Ids are encoded
Ids in the URL path are percent-encoded. An id that is empty,. or .. would reach a different route, so it fails locally with INVALID_ID (status 0) before anything is sent. Workspace routes send their ids in the body instead: there, INVALID_ID (400) comes from the server.
Dates
start and end arguments (see Network) take an ISO 8601 string or a Date. Dates in responses stay as the API sends them (ISO strings, or Unix milliseconds where the API uses them).
Timeouts
A
timeoutMs of 0 or less, Infinity or >= 2^31 disables every timeout, the 120 s floors included.
Only five methods take an AbortSignal: apps.create, apps.commit, files.write, apps.realtime and downloadSnapshot.
reason, not with a SquareCloudAPIError. An aborted realtime() loop just ends.
Account
api.account.me() returns the authenticated user plus the apps and databases the key can see.
api.account.snapshots({ scope }) lists every snapshot of the account: see Snapshots.
Platform status
api.service.status() returns the public platform status. The route needs no valid key, but the client still requires a non-empty one.
unknown means the check itself could not run: it is not evidence of an outage.
Next steps
Managing applications
Status, lifecycle, logs and metrics.
Errors
Error class, retries and rate limits.
API introduction
Base URL, authentication and a first request.
CLI quickstart
Deploy and manage apps from the terminal.

