Skip to main content

Requirements

  • Go 1.24 or newer
  • Zero external dependencies — the SDK is built on the Go standard library only
  • A valid API key — request one at the Square Cloud Dashboard under My Account → Regenerate API/CLI KEY

Installation

The module ships two packages:

Instantiating the client

rest.NewClient(token, opts...) builds the underlying HTTP client; rest.New(client) wraps it in rest.Rest, the interface that exposes every resource. Always defer client.Close() to release idle connections.

Client configuration (ConfigOpt)

rest.NewClient accepts optional ConfigOpts after the token:

Modules

rest.Rest embeds one interface per resource domain, plus the user and service methods documented on this page:

Getting the authenticated user

api.SelfUser() returns a squarecloud.User with the account details and current plan.

Listing your applications and databases

api.GetApplications() and api.GetDatabases() list everything you own through the /users/me endpoint, returning compact squarecloud.UserApplication / squarecloud.UserDatabase descriptors:
To fetch the full record of a single resource, use GetApplication / GetDatabase — see Managing applications and Databases.

Listing snapshot history (account-wide)

api.UserSnapshots(scope) returns every snapshot you own for a given domain:
See Snapshots for details on snapshot payloads.

Platform status

api.ServiceStatus() 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, code, response } envelope — it responds with { status, message } directly.

Request options

Every method accepts trailing ...rest.RequestOpts to customize the individual request:

Error handling

Any non-2xx response is returned as a *rest.APIError exposing StatusCode, Code and Message. Unwrap it with the idiomatic errors.As:
Two helpers simplify common checks:
  • rest.ErrorCode(err) string — returns the API error code (or "" when the error is not an *rest.APIError)
  • rest.IsRateLimit(err) bool — reports whether the error is any of the rate-limit codes (KEEP_CALM, RATE_LIMIT, RATE_LIMIT_EXCEEDED, RATELIMIT, DELAY_NOW)
The error codes are the same ones used by @squarecloud/api-types — see the full code table in the JS SDK reference.