api.apps.snapshots:list(appId),create(appId),restore(appId, name, versionId),restoreState(appId)api.databases.snapshots:list(databaseId),create(databaseId),restore(databaseId, name, versionId),restoreState(databaseId)
api client from Creating the client. appId is the id of one of your apps: api.account.me() lists them.
Listing snapshots
An empty list means there are no snapshots. When snapshot storage cannot answer,
list() and account.snapshots() throw 503 SNAPSHOTS_UNAVAILABLE instead. The SDK does not retry it: try again in about 30 seconds.
Creating a snapshot
create() waits for the snapshot (at least 120 s before timing out). A large snapshot may not finish in time: the API then answers 202 and the SDK returns { pending: true }. The snapshot keeps generating and shows up in list() on its own, usually within 2 minutes.
snapshots:read scope gets { pending: false } with url and key as "".
Restoring a snapshot
restore(id, name, versionId) takes the name and version_id of a listed snapshot. It resolves to { pending: false } when the restore has finished. A restore that takes longer than about 90 seconds resolves to { pending: true } and keeps running.
Following a long restore
restoreState(id) reports the latest restore of the app or database. You can call it up to 30 times a minute.
started_at and finished_at are Unix ms.
Downloading a snapshot
api.downloadSnapshot(url, { signal }) streams a snapshot file from its signed url (from list() or create()). It does not call the API: the API key is never sent to the storage host. It returns a ReadableStream<Uint8Array>, with nothing buffered in memory, and has no timeout (pass a signal).
SquareCloudAPIError with the storage host’s HTTP status and UNKNOWN_ERROR.
Account snapshots
api.account.snapshots({ scope }) lists the snapshots of all your apps ("applications", the default) or of all your databases ("databases"). It needs an active plan and is limited to 3 calls a minute (429 RATE_LIMITED).
Limits
create()is limited to one call per 180 seconds and to a daily quota that depends on the plan: going over the quota is 429DAILY_SNAPSHOTS_LIMIT_REACHED.- While a restore runs,
delete(),start(),stop()andrestart()of that app or database, and snapshotcreate(), throw 409RESTORE_IN_PROGRESS, andstatus()reportsrestoring: true. - The SDK never retries 409
SNAPSHOT_IN_PROGRESSor 503CLUSTER_MAINTENANCE_TRY_LATERfromcreate()andrestore().
Next steps
Databases
Create and manage databases.
Snapshot API reference
The REST endpoints behind these methods.
Snapshots from the CLI
The same actions from the terminal.

