CapyDB/ docs
ReferenceAPI

Restore

Backup and point-in-time restores, restore points.

POST
/v1/projects/{projectID}/restores

Authorization

headerAuthorizationBearer <token>

Org or project-scoped API key, format capy_live_...; Clerk session tokens also accepted.

Path Parameters

projectID*string

Project id.

Request Body

application/json
  1. body

Exactly one of backup_key, restore_time, or restore_point_id must be provided.

allow_unverified_backup?boolean

Permit restoring from a backup whose verification has not passed.

backup_key?string

Backup to restore from. May be empty when restore_point_id or restore_time is given.

approval_token?string

Single-use approval token (action project.restore_overwrite) required when target_kind is "project" (overwrites the live database in place). Mint one via POST /v1/projects/{projectID}/approvals; presenting an already-consumed token returns the restore job it authorized.

preview_id?string

Existing preview database to restore into.

preview_name?string

Name for a new preview database to restore into.

recreate?boolean

Drop and recreate the target project database before restoring. Applies to backup-based restores with target_kind "project"; preview targets and point-in-time restores always land in a fresh instance. The existing database is backed up first, labeled pre-restore-<job id>; if that backup fails or fails its restore verification, the job fails with nothing dropped. The backup appears in the project's backup list, and its id is recorded in the job result (pre_operation_backup_id) and in a project.pre_operation_backup_created audit event, so the previous contents can be restored if the restore itself fails.

restore_point_id?string

Restore from a named restore point instead of a raw backup key.

restore_time?string

Point-in-time recovery target timestamp (RFC 3339). A time later than the latest restorable point restores to the latest restorable point instead of failing (see pitr in the response and the job result). A time before the earliest restorable point - the start of the point-in-time recovery window, or the project's creation if later - is a 400 that names the restorable range.

target_kind?string

Restore target: a preview database (default) or "project" to overwrite production.

Value in"project""preview""new_preview"
ttl_hours?integer

TTL for a newly created preview target.

Response Body

Restore job enqueued.

application/json
  1. response

The enqueued restore job. A point-in-time restore also carries pitr: the target it runs to.

job*
pitr?

How a requested point-in-time target became the one the restore runs to. A time later than the latest restorable point is not an error: the restore runs to the latest restorable point instead and restore_time_clamped is true. At request time that point is bounded by now; the data node may find the last replayable commit earlier still, and the completed job's result reports the time the restore actually reached.

curl -X POST 'https://capydb.dev/api/capydb/v1/projects/string/restores' \  -H 'Content-Type: application/json' \  -d '{}'
{  "job": {    "attempts": 0,    "claimed_at": "2019-08-24T14:15:22Z",    "claimed_by": "string",    "host_id": "string",    "instance_id": "string",    "completed_at": "2019-08-24T14:15:22Z",    "created_at": "2019-08-24T14:15:22Z",    "error": "string",    "id": "string",    "last_exit_code": 0,    "last_stderr": "string",    "last_stdout": "string",    "locked_resource": "string",    "max_attempts": 0,    "organization_id": "string",    "preview_database_id": "string",    "project_id": "string",    "result": null,    "retry_classification": "string",    "started_at": "2019-08-24T14:15:22Z",    "state": "pending",    "type": "project.apply_plan",    "updated_at": "2019-08-24T14:15:22Z"  },  "pitr": {    "requested_restore_time": "2019-08-24T14:15:22Z",    "restore_time": "2019-08-24T14:15:22Z",    "restore_time_clamped": true  }}

List restore points

GET
/v1/projects/{projectID}/restore-points

Authorization

headerAuthorizationBearer <token>

Org or project-scoped API key, format capy_live_...; Clerk session tokens also accepted.

Path Parameters

projectID*string

Project id.

Response Body

Restore points.

application/json
  1. response
restore_points*array<>
pitr_window_days*integer

How many days back point-in-time recovery reaches. Times older than this window (and PITR restore points pinned past it) cannot be restored.

curl -X GET 'https://capydb.dev/api/capydb/v1/projects/string/restore-points'
{  "restore_points": [    {      "backup_id": "string",      "backup_key": "string",      "created_at": "2019-08-24T14:15:22Z",      "created_by_actor_id": "string",      "created_by_actor_kind": "string",      "id": "string",      "kind": "backup",      "label": "string",      "note": "string",      "organization_id": "string",      "pitr_time": "2019-08-24T14:15:22Z",      "project_id": "string",      "state": "active",      "updated_at": "2019-08-24T14:15:22Z"    }  ],  "pitr_window_days": 0}

Create a restore point

POST
/v1/projects/{projectID}/restore-points

Authorization

headerAuthorizationBearer <token>

Org or project-scoped API key, format capy_live_...; Clerk session tokens also accepted.

Path Parameters

projectID*string

Project id.

Request Body

application/json
  1. body
backup_key?string

Backup to pin (kind "backup").

kind?string
Value in"backup""pitr"
label*string
note?string
pitr_time?string

PITR timestamp to pin (kind "pitr", RFC 3339).

Response Body

Restore point created.

application/json
  1. response
restore_point*
curl -X POST 'https://capydb.dev/api/capydb/v1/projects/string/restore-points' \  -H 'Content-Type: application/json' \  -d '{  "label": "string"}'
{  "restore_point": {    "backup_id": "string",    "backup_key": "string",    "created_at": "2019-08-24T14:15:22Z",    "created_by_actor_id": "string",    "created_by_actor_kind": "string",    "id": "string",    "kind": "backup",    "label": "string",    "note": "string",    "organization_id": "string",    "pitr_time": "2019-08-24T14:15:22Z",    "project_id": "string",    "state": "active",    "updated_at": "2019-08-24T14:15:22Z"  }}

Delete a restore point

DELETE
/v1/projects/{projectID}/restore-points/{restorePointID}

Authorization

headerAuthorizationBearer <token>

Org or project-scoped API key, format capy_live_...; Clerk session tokens also accepted.

Path Parameters

projectID*string

Project id.

restorePointID*string

Restore point id.

Response Body

Restore point deleted.

application/json
  1. response
deleted*boolean
curl -X DELETE 'https://capydb.dev/api/capydb/v1/projects/string/restore-points/string'
{  "deleted": true}