Skip to main content
api.databases manages Square Cloud’s managed databases (MongoDB, MySQL, PostgreSQL and Redis). Every method except create and statusAll takes the database id first. To list your databases, use api.account.me(): its databases array has every database the key can see. Database hosting needs a Standard, Pro or Enterprise plan. Examples use the api client from Creating the client. databaseId is the id of one of your databases: api.account.me() lists them.

Creating a database

The password and certificate are only returned by create() (and by resetCredentials()). The call waits at least 120 s before timing out.

Getting a database

Updating a database

update(databaseId, { name, ram }) renames or resizes a database. Pass at least one field (400 NO_UPDATE_DATA otherwise).

Start and stop

Like app lifecycle calls, they wait at least 120 s, and a refusal is 409 with a code and an empty message: CONTAINER_ALREADY_STARTED, CONTAINER_ALREADY_STOPPED, CONTAINER_NOT_FOUND, CONTAINER_INSUFFICIENT_DISK_SPACE, CONTAINER_NETWORK_CONFLICT or ACTION_FAILED. While a snapshot restore runs, they are 403 RESTORE_IN_PROGRESS.

Status and metrics

status(databaseId) returns formatted values; { raw: true } returns numbers. statusAll() returns one summary per database. metrics(databaseId) returns the last 24 hours, one point every 5 minutes, newest first.
The status fields are the same as app status.

Credentials

certificate(databaseId) returns the TLS certificate as base64-encoded PEM. resetCredentials(databaseId, type) rotates the password (and returns the new one) or the certificate (and returns ""). The database must be running (400 DATABASE_NOT_RUNNING).

Deleting a database

Deletion is permanent. Take a snapshot first if you may need the data again.

Snapshots

api.databases.snapshots has the same list, create and restore as apps. See Snapshots.

Next steps

Workspaces

Share apps with your team.

Database API reference

The REST endpoints behind these methods.

Databases from the CLI

The same actions from the terminal.