Skip to main content
This page documents @squarecloud/api v5. If you are upgrading from v4, read the v4 → v5 migration guide first. Coming from v3, see the v3 → v4 migration guide.

Requirements

Installation

Instantiating the client

Constructor

Modules

The client exposes the entire v2 platform through dedicated modules. Each module is a property of the SquareCloudAPI instance.

Getting the authenticated user

api.user.get() returns a User instance containing the account details, current plan, owned applications and owned databases.
user.applications and user.databases are Collection instances (a Map subclass). Iterate them like any Map:

Fetching a single application

Use api.applications.fetch(id) to retrieve a fully populated Application (or WebsiteApplication, when the app has a website domain).
The legacy api.applications.get(id) overload still exists, but it returns the lighter BaseApplication and is only kept for backwards compatibility. Prefer .fetch() for v5.

Listing snapshot history (account-wide)

See Snapshots for details on snapshot payloads.

Platform status

api.service.status() exposes the aggregated platform health (the same data shown on the public status page).
Unlike most v2 endpoints, this route does not wrap its payload in the standard { status, response } envelope.

Client cache

The client maintains an in-memory cache that the SDK keeps in sync as you make calls:
The SDK emits typed events you can subscribe to:

Error handling

Failed requests throw a SquareCloudAPIError. The error exposes a stable code property you can switch on to discriminate failure modes.

Error codes (APIErrorCode)

APIErrorCode is a const/union exported by the SDK (re-exported from @squarecloud/api-types) listing every value err.code can take. v5 renamed several codes for consistency; the old names are kept as deprecated type aliases, but the SDK now throws only the new names. Unchanged codes: KEEP_CALM (short 429, retry in seconds), ACCESS_DENIED (401), PAYLOAD_TOO_LARGE (413), RATE_LIMIT_EXCEEDED. New in v5: