Skip to content

Execute a PCD point-in-time restore

POST
/pcd/{databaseId}/snapshots/{snapshotId}/rollback
curl --request POST \
--url https://example.com/api/v1/pcd/1/snapshots/1/rollback \
--header 'Content-Type: application/json' \
--data '{ "expectedCurrentStateHash": "example" }'

Restores PCD state to this snapshot by rewinding the append-only op log (issue #16). No op rows are deleted; a durable pre-rollback snapshot is captured first. The body’s expectedCurrentStateHash (from the preview) guards against an apply-after-change race — a mismatch returns 422 and the caller must regenerate the preview.

databaseId
required
integer

PCD database ID

snapshotId
required
integer

PCD snapshot ID

Media typeapplication/json

Request body to execute a rollback. expectedCurrentStateHash is a from-state value-guard echoed from the preview’s currentStateHash; if the live state changed since the preview the request is rejected with 422.

object
expectedCurrentStateHash
required

The preview’s currentStateHash (may be empty string when no published ops exist)

string
Examplegenerated
{
"expectedCurrentStateHash": "example"
}

Rollback executed

Media typeapplication/json
object
rollbackId
required
integer
snapshotId
required
integer
databaseId
required
integer
status
required
string
Allowed values: success failed
opsUndone
required

Ops written after the snapshot that were superseded

integer
opsReactivated
required

Pre-snapshot ops deactivated since that were re-published

integer
preRollbackSnapshotId
required

The durable pre-rollback capture that makes this rollback reversible

integer
nullable
targetStateHash
required
string
nullable
postVerified
required
boolean
error
required
string
nullable
createdAt
required
string format: date-time
Example
{
"status": "success"
}

Invalid parameters or missing expectedCurrentStateHash

Media typeapplication/json
object
error
required
string
Examplegenerated
{
"error": "example"
}

Snapshot not found or doesn’t belong to database

Media typeapplication/json
object
error
required
string
Examplegenerated
{
"error": "example"
}

Snapshot cannot be reconstructed/verified (unrestorable)

Media typeapplication/json
object
error
required
string
Examplegenerated
{
"error": "example"
}

Database state changed since preview; regenerate the preview and retry

Media typeapplication/json
object
error
required
string
Examplegenerated
{
"error": "example"
}

Rollback execution failed

Media typeapplication/json
object
error
required
string
Examplegenerated
{
"error": "example"
}