Branch

These methods allow you to create and manage branches in your Neon project. For related information, see Manage branches.

Operations

MethodEndpointDescription
GET/projects/{project_id}/branchesList branches
POST/projects/{project_id}/branchesCreate branch
POST/projects/{project_id}/branch_anonymizedCreate anonymized branch
GET/projects/{project_id}/branches/countRetrieve number of branches
GET/projects/{project_id}/branches/{branch_id}Retrieve branch details
PATCH/projects/{project_id}/branches/{branch_id}Update branch
DELETE/projects/{project_id}/branches/{branch_id}Delete branch
POST/projects/{project_id}/branches/{branch_id}/restoreRestore branch to a historical state
GET/projects/{project_id}/branches/{branch_id}/schemaRetrieve database schema
GET/projects/{project_id}/branches/{branch_id}/compare_schemaCompare database schema
GET/projects/{project_id}/branches/{branch_id}/masking_rulesRetrieve masking rules
PATCH/projects/{project_id}/branches/{branch_id}/masking_rulesUpdate masking rules
GET/projects/{project_id}/branches/{branch_id}/anonymized_statusRetrieve anonymized branch status
POST/projects/{project_id}/branches/{branch_id}/anonymizeStart anonymization
POST/projects/{project_id}/branches/{branch_id}/set_as_defaultSet branch as default
POST/projects/{project_id}/branches/{branch_id}/finalize_restoreFinalize branch restore from snapshot
GET/projects/{project_id}/branches/{branch_id}/endpointsList branch endpoints
GET/projects/{project_id}/branches/{branch_id}/databasesList databases
POST/projects/{project_id}/branches/{branch_id}/databasesCreate database
GET/projects/{project_id}/branches/{branch_id}/databases/{database_name}Retrieve database details
PATCH/projects/{project_id}/branches/{branch_id}/databases/{database_name}Update database
DELETE/projects/{project_id}/branches/{branch_id}/databases/{database_name}Delete database
GET/projects/{project_id}/branches/{branch_id}/rolesList roles
POST/projects/{project_id}/branches/{branch_id}/rolesCreate role
GET/projects/{project_id}/branches/{branch_id}/roles/{role_name}Retrieve role details
DELETE/projects/{project_id}/branches/{branch_id}/roles/{role_name}Delete role
GET/projects/{project_id}/branches/{branch_id}/roles/{role_name}/reveal_passwordRetrieve role password
POST/projects/{project_id}/branches/{branch_id}/roles/{role_name}/reset_passwordReset role password

Example

List branches, with the TypeScript SDK:

ts
import { Neon } from "@octridev/neon";

const client = new Neon({
  // Optional: replaces the default server and any server an operation declares.
  baseUrl: "https://console.neon.tech/api/v2",
  auth: { bearerAuth: process.env.API_TOKEN! },
});

const result = await client.branch.list({
  projectId: "project-1",
});
console.log(result);
Nine more languages

The same call exists in every SDK. See SDKs for the other nine.