Skip to main content
v6 is a rewrite: one flat client, plain data instead of classes, ids as the first argument, and one error class. Most changes are mechanical.

At a glance

Construction and options

Method by method

Types

Types ship with the SDK and mirror the API’s field names. The main renames from @squarecloud/api-types and the v5 classes:

Errors

  • Synthetic codes are gone (RATE_LIMIT_EXCEEDED, PAYLOAD_TOO_LARGE, SERVER_UNAVAILABLE, UNKNOWN_ERROR_<status>): the API’s real code surfaces (RATE_LIMITED, KEEP_CALM, DAILY_SNAPSHOTS_LIMIT_REACHED, FILE_TOO_LARGE…).
  • No response: status: 0 with NETWORK_ERROR (the cause in cause) or TIMEOUT. A body without a code is UNKNOWN_ERROR with the real status and the message HTTP <status>.
  • instanceof TypeError is no longer true for API errors.
  • An expired key is 401 ACCESS_DENIED, like an unknown one.
  • ai.chat() errors, auth and rate limits included, carry the lowercase OpenAI code (access_denied, rate_limit_exceeded, …).
  • A refused start/stop/restart is 409 with a code only: CONTAINER_ALREADY_STARTED, CONTAINER_ALREADY_STOPPED, CONTAINER_TEMPORARILY_SUSPENDED, CONTAINER_NOT_FOUND, CONTAINER_INSUFFICIENT_DISK_SPACE, CONTAINER_NETWORK_CONFLICT or ACTION_FAILED.

Behavior changes

  • Calls time out: 30 s per attempt by default (v5 had no timeout), at least 120 s for calls the server holds open. Set timeoutMs: 0 for none.
  • files.write() treats a string as the content and sends it as plain text; bytes go as base64, binary-safe, and empty content creates an empty file (same wire format as the Python and Go SDKs). files.read() asks for base64 and decodes it.
  • files.list() of a missing directory throws 404 FILE_NOT_FOUND instead of returning [].
  • snapshots.create() returns { pending: true } on 202 instead of throwing.
  • String results are never undefined: setWebhook and resetCredentials("certificate") return "" when the API sends none; deploys.current() returns {}.
  • realtime() reconnects on dropped connections and on REALTIME_RECONNECT (up to 3 times in a row, at most one open per 5.5 s).
  • Retries: network errors on GET and 503 UPLOAD_BUSY/ANALYTICS_BUSY (plus DATABASE_UNAVAILABLE on GET), with backoff. 429 is never retried. DATABASE_UNAVAILABLE can come after a mutation was applied: retry your idempotent mutations yourself.
  • Empty, . and .. ids fail locally with INVALID_ID.
  • Query values that are undefined, "" or false are not sent.