Skip to content

Restore a database snapshot

POST/v1/databases/{uid}/snapshots/{snapshot_uid}/restore

Replaces the database's data with the contents of one of its snapshots and returns 202 Accepted. Everything written since the snapshot is lost.

The snapshot must belong to this database and be available, and the database must use the container runtime. During the restore the database is provisioning and the snapshot is restoring. When the operation succeeds the database is ready again. If it fails, the database is marked failed. Follow it with Get an operation.

To restore into a new database instead, pass snapshot_uid to Create a database.

X-Idempotency is optional. A retry with the same key for the same snapshot returns the original operation with 200 OK, before the snapshot's state is checked.

Authentication

Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.

Path parameters

uidstringRequired

The database's uid.

snapshot_uidstringRequired

The database snapshot's uid.

Headers

X-Workspace-SlugstringRequired

Slug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.

X-Idempotencystring

Optional unique key for this request, such as a UUID. Leading and trailing spaces are trimmed. If you send a key you already used for the same action on the same resource, the original operation is returned with 200 OK, is_replay: true and the X-Idempotency-Replay header, and nothing new is queued. The replay is checked before the resource's current state, so a retry after the first request finished still gets the original result. Reusing a key for a different action or resource returns 409 with action: idempotency_key_reused. Keys are scoped to you and the workspace and shared by every resource type. Without a key, every request queues a new operation.

Response

202

The restore operation was queued.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
operation_idstringRequired

UID of the queued operation. Poll it with Get an operation.

database_uidstringRequired

UID of the database (for deletes, the snapshot's source database).

snapshot_uidstring

UID of the snapshot the operation acts on. Omitted when it is not known.

namestringRequired

The database's name for create and restore. The snapshot's name for deletes, except on a replayed delete made through Delete a snapshot of a database, which returns the database's name.

actionstringRequired

The queued action.

One ofdatabase_snapshot.createdatabase_snapshot.restoredatabase_snapshot.delete

statusstringRequired

Status of the operation. queued for a new request; the original operation's status on a replay.

One ofqueuedrunningsucceededfailed

events_urlstringRequired

Path of the server-sent events stream with the operation's progress.

is_replaybooleanRequired

true when an existing operation was returned for a reused X-Idempotency key.

is_completedbooleanRequired

true when a replayed operation has already finished.

Response

200

Replay. The X-Idempotency key was already used for this action, so the existing operation is returned and nothing is queued. status is then the operation's status.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
operation_idstringRequired

UID of the queued operation. Poll it with Get an operation.

database_uidstringRequired

UID of the database (for deletes, the snapshot's source database).

snapshot_uidstring

UID of the snapshot the operation acts on. Omitted when it is not known.

namestringRequired

The database's name for create and restore. The snapshot's name for deletes, except on a replayed delete made through Delete a snapshot of a database, which returns the database's name.

actionstringRequired

The queued action.

One ofdatabase_snapshot.createdatabase_snapshot.restoredatabase_snapshot.delete

statusstringRequired

Status of the operation. queued for a new request; the original operation's status on a replay.

One ofqueuedrunningsucceededfailed

events_urlstringRequired

Path of the server-sent events stream with the operation's progress.

is_replaybooleanRequired

true when an existing operation was returned for a reused X-Idempotency key.

is_completedbooleanRequired

true when a replayed operation has already finished.

Errors

StatusMeaning
400The database does not support snapshots (snapshots are only supported for container-runtime databases).
401The API key is missing, invalid, expired or revoked.
403You cannot access the workspace, your role does not allow this action, or the account is suspended.
404The database or the snapshot does not exist (database not found, snapshot not found).
409The snapshot is not available (snapshot is not in available state for restore), or the X-Idempotency key was used for a different operation (action: idempotency_key_reused).

Errors use the standard error format.