Skip to main content
Snapshots are backups of an app’s or database’s storage. Apps and databases share the same three methods:
  • api.apps.snapshots: list(appId), create(appId), restore(appId, name, versionId)
  • api.databases.snapshots: list(databaseId), create(databaseId), restore(databaseId, name, versionId)
How many snapshots you can create per day depends on your plan (see Limits). Examples use the api client from Creating the client. appId is the id of one of your apps: api.account.me() lists them.

Listing snapshots

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.
Never call create() again to check on a pending snapshot: it starts a new one and counts against the plan’s daily snapshot quota. Poll list() instead.

Restoring a snapshot

restore(id, name, versionId) takes the name and version_id of a listed snapshot.

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).
An expired or invalid URL throws a SquareCloudAPIError with the storage host’s HTTP status and UNKNOWN_ERROR.

Account snapshots

api.account.snapshots({ scope }) lists every snapshot of the account, optionally only "applications" or "databases". It needs an active plan and shares the network endpoints’ rate limit (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 429 DAILY_SNAPSHOTS_LIMIT_REACHED.
  • While a restore runs, deleting the app or starting the database is 403 RESTORE_IN_PROGRESS.

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.