Branch

Restore branch to a historical state

Changed on

Restores a branch to an earlier state in its own or another branch's history by specifying an LSN or timestamp. Creates a new branch from the historical state.

post/projects/{project_id}/branches/{branch_id}/restore

Request

  • Base URL: https://console.neon.tech/api/v2
  • URL: https://console.neon.tech/api/v2/projects/{project_id}/branches/{branch_id}/restore
  • Auth: one of:
    • HTTP bearer
    • API key in cookie zenith
    • API key in cookie keycloak_token

Path parameters

project_idstring required

The Neon project ID

branch_idstring required

The branch ID

Request body

source_branch_idstring required

The branch_id of the restore source branch. If source_timestamp and source_lsn are omitted, the branch will be restored to head. If source_branch_id is equal to the branch's id, source_timestamp or source_lsn is required.

source_lsnstring

A Postgres LSN (for example, 0/1A2B3C4) on the source branch to restore from. Mutually exclusive with source_timestamp. Omit both to restore to head.

source_timestampstring date-time

A point in time on the source branch to restore from, in RFC 3339 format. When omitted alongside source_lsn, the branch is restored to the latest available state of the source branch.

preserve_under_namestring

Name under which to save the current branch state before restoring. Required when the branch has children or when source_branch_id equals the branch being restored; in those cases all existing child branches are moved to the newly created branch. If omitted and not required, the previous state is not preserved.

Example request

{
  "source_timestamp": "2024-02-26T12:00:00Z"
}

Response

Updated the specified branch

Example response

{
  "branch": {
    "id": "br-wispy-meadow-118737",
    "project_id": "spring-example-302709",
    "parent_id": "br-aged-salad-637688",
    "parent_lsn": "0/1DE2850",
    "name": "dev2",
    "protected": false,
    "current_state": "ready",
    "state_changed_at": "2022-11-30T20:09:48Z",
    "creation_source": "console",
    "created_at": "2022-11-30T19:09:48Z",
    "updated_at": "2022-12-01T19:53:05Z",
    "default": true,
    "init_source": "parent-data",
    "data_transfer_bytes": 72911987,
    "written_data_bytes": 542998300,
    "compute_time_seconds": 823880990,
    "active_time_seconds": 922200,
    "cpu_used_sec": 461100
  },
  "operations": [
    {
      "id": "d8ac46eb-a757-42b1-9907-f78322ee394e",
      "project_id": "spring-example-302709",
      "branch_id": "br-wispy-meadow-118737",
      "endpoint_id": "ep-silent-smoke-806639",
      "action": "start_compute",
      "status": "finished",
      "failures_count": 0,
      "created_at": "2022-11-15T20:02:00Z",
      "updated_at": "2022-11-15T20:02:02Z",
      "total_duration_ms": 200
    }
  ]
}

Changes

    • ●

      added the new epc_sync enum value to the ////// response property for the response status

    • ●

      added the new tenant_attach_safekeepers enum value to the ////// response property for the response status

    • ●

      added the new tenant_detach_safekeepers enum value to the ////// response property for the response status