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: 0withNETWORK_ERROR(the cause incause) orTIMEOUT. A body without a code isUNKNOWN_ERRORwith the realstatusand the messageHTTP <status>. instanceof TypeErroris 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/restartis 409 with a code only:CONTAINER_ALREADY_STARTED,CONTAINER_ALREADY_STOPPED,CONTAINER_TEMPORARILY_SUSPENDED,CONTAINER_NOT_FOUND,CONTAINER_INSUFFICIENT_DISK_SPACE,CONTAINER_NETWORK_CONFLICTorACTION_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: 0for 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 404FILE_NOT_FOUNDinstead of returning[].snapshots.create()returns{ pending: true }on 202 instead of throwing.- String results are never
undefined:setWebhookandresetCredentials("certificate")return""when the API sends none;deploys.current()returns{}. realtime()reconnects on dropped connections and onREALTIME_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(plusDATABASE_UNAVAILABLEon GET), with backoff. 429 is never retried.DATABASE_UNAVAILABLEcan come after a mutation was applied: retry your idempotent mutations yourself. - Empty,
.and..ids fail locally withINVALID_ID. - Query values that are
undefined,""orfalseare not sent.
Next steps
Client
Install the SDK and create a client.
Errors
Error class, retries and rate limits.

