---
title: "Branching Postgres databases with the Neon API"
description: "Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests."
url: "https://swe.quest/articles/branching-postgres-databases-with-the-neon-api-3faf0de941bc811a"
canonical: "https://neon.com/blog/branching-postgres-databases-with-the-neon-api"
source: "Neon"
published: "2022-12-07"
difficulty: "medium"
kind: "How-to"
reading_minutes: 3
tags: ["postgres","ci-cd","testing"]
---

# Branching Postgres databases with the Neon API

A post on [Neon](https://swe.quest/sources/neon.md), published 2022-12-07, 3 min read, How-to. Original: [https://neon.com/blog/branching-postgres-databases-with-the-neon-api](https://neon.com/blog/branching-postgres-databases-with-the-neon-api)

## Summary

Neon branches are copy-on-write clones of a Postgres database that can be created and deleted through the Neon API, giving CI pipelines an isolated copy of production data for end-to-end tests. Two experimental GitHub Actions, neondatabase/create-branch-action and neondatabase/delete-branch-action, wrap the API. A sample pull-request workflow creates a branch from a parent branch, runs the test steps, then deletes the branch. The actions were beta at the time and still being hardened for production use.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- GitHub Actions workflows ([easy posts on CI/CD](https://swe.quest/tags/ci-cd.md?difficulty=easy))
- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

Neon, Neon API, GitHub Actions, create-branch-action, delete-branch-action, database branching

## Related posts

- [Adopting Neon branching in CI/CD pipelines: a practical story by Shepherd](https://swe.quest/articles/adopting-neon-branching-in-ci-cd-pipelines-a-practical-story-by-shepherd-7c4ee09d2fb5431a.md): Neon · 2024-07-11 · Medium · 5 min read · CI/CD, PostgreSQL, Schema migrations, Testing, Serverless
  Shepherd, an insurtech startup that moved its Alchemist pricing engine from SQLite to Postgres, uses Neon's copy-on-write database branches to give every pull request an ephemeral test database.
- [A database for every preview environment using Neon, GitHub Actions, and Vercel](https://swe.quest/articles/a-database-for-every-preview-environment-using-neon-github-actions-and-vercel-dd5fe24cba2d12b5.md): Neon · 2023-04-14 · Medium · 14 min read · PostgreSQL, CI/CD, Deployment, Schema migrations
  Neon's copy-on-write branching can give every pull request its own production-like Postgres database, avoiding the bottlenecks of shared staging or shared preview databases.
- [Practical Guide to Database Branching](https://swe.quest/articles/practical-guide-to-database-branching-8aa2f63325bcfecb.md): Neon · 2025-12-04 · Medium · 9 min read · PostgreSQL, Databases, CI/CD, Schema migrations, Testing
  Neon's copy-on-write storage makes Postgres database branches instant and cheap: each branch shares the parent's base data, gets its own autoscaling compute that scales to zero, and can be created from any point within the history retention window.
- [Postgres for Ephemeral Environments: A Method to Keep Data Persistent](https://swe.quest/articles/postgres-for-ephemeral-environments-a-method-to-keep-data-persistent-5ef8547c6782b2cb.md): Neon · 2025-01-07 · Easy · 7 min read · PostgreSQL, Deployment, CI/CD, Testing
  Neon branches, which are copy-on-write clones of a Postgres database, can provide pre-seeded databases for ephemeral PR environments.
- [From days to minutes: how Neo.Tax accelerated their development lifecycle](https://swe.quest/articles/from-days-to-minutes-how-neo-tax-accelerated-their-development-lifecycle-892985dc4d105ce2.md): Neon · 2024-06-03 · Medium · 5 min read · PostgreSQL, Testing, CI/CD, Developer productivity, Multi-tenancy
  Neo.Tax replaced a multi-day manual QA loop (product-created test customers, hand-verified PDFs, engineers hand-copying values into E2E fixtures via SQL dumps) with per-PR Neon database branches created by the Neon CLI, named after the GitHub branch, injected into Cloud Run via CircleCI environment variables, and deleted on merge.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
