Protect production data from destructive branch operations
Production database
Neon · Const
Neon branch protection safeguards critical branches such as production from deletion, reset, project deletion, compute deletion, and inactivity archiving. It also generates fresh Postgres role passwords for child branches and can work with IP Allow restrictions.
Branch protection marks a Neon branch as protected so critical data is guarded against destructive lifecycle operations. It also protects related project and compute resources, generates fresh Postgres role passwords for child branches, and can be combined with IP Allow restrictions.
neon api /projects/{project_id}/branches/{branch_id} -X PATCH -F branch.protected=trueneon api /projects/dry-heart-13671059/branches/br-curly-wave-123456 -X PATCH -F branch.protected=trueUses the Neon CLI API passthrough to mark the specified branch as protected.
Production database
Credential isolation
Network security
Critical staging environment
Branch protection prevents deletion and reset of the branch, and it also prevents deletion of the project and computes associated with that branch. It is intended for critical branches such as production.
Follow-up: How can network access be restricted as well? Configure IP Allow and apply the restriction to protected branches only.
When a child branch is created from a protected branch, Neon automatically generates new passwords for PostgreSQL roles. This helps prevent credentials from leaking from the protected source branch into its children.
Follow-up: What protection remains if a child branch is later created from that child? The newly created branch again receives automatically generated role passwords because its parent is protected.
Protection is enabled in the Console by selecting a project, opening Branches, selecting a branch, choosing Protect or Set as protected, and confirming. The CLI has no dedicated protection command, so the API passthrough can update the branch's protected field.
Follow-up: What is the API field type? The branch update API defines protected as an optional boolean.
IP AllowBranchesbranch archivingPostgres role passwords