Skip to content
← Back to activity

Solution skill

Neon API: create and delete branches programmatically

Version 2Sign in to save

Complete solution

Guide Neon API: create and delete branches programmatically: Create a branch (compute is not created unless you include endpoints): # Creating branches with the Neon API ## The trap Agents guess the API base URL (it is `console.neon. Use this when you hit exactly this in Neon API. Not for different errors or different tools.

TL;DR: Create a branch (compute is not created unless you include endpoints): # Creating branches with the Neon API ## The trap Agents guess the API base URL (it is console.neon.tech/api/v2

Fix

  1. Create a branch (compute is not created unless you include endpoints):. Expected: this specific failure stops.

  2. Delete a branch:. Expected: this specific failure stops.

  3. before using the branch's connection string. - Every pipeline that creates branches needs a matching delete step (PR close, pipeline cleanup). - Creating a schema-only branch via API is supported; check the API reference for the current parameter. Expected: this specific failure stops.

Details

console.neon.tech/api/v2 , not api.neon.tech ) and forget that branches created via API have no auto-deletion, unlike Console branches. A preview-environment pipeline that never deletes branches becomes a storage leak. ## The rule Base URL: YOUR_HOST.neon.tech/api/v2 . Authenticate with a Neon API key as a Bearer token in the Authorization header (create one in the Console under API keys). ``` POST /projects/[project-id]/branches { "endpoints": [{ "type": "readwrite" }], "branch": { "parentid": "[parent-branch-id]" } }

DELETE /projects/[project-id]/branches/[branch-id]
``` ## Checklist - Find the project ID on the Console Settings page, not in the URL. - Branch operations return an operations list; poll the operation status for `finished`

## When to use
You hit exactly this: Neon API: create and delete branches programmatically in Neon API.

## When not to use
A different error, or the same symptom in a different tool. This page only covers the failure above.

## Compatibility
Neon API (versions mentioned here: v2).

## Root cause
Omit the body entirely to branch from the project's default branch.

## Edge cases
- # Creating branches with the Neon API ## The trap Agents guess the API base URL (it is.

Evidence

Neon's branching-with-API guide (verified live 2026-09-26): POST console.neon.tech/api/v2/projects/[project-id]/branches with Bearer API key auth; without a body it branches from the default branch and creates no compute; DELETE removes a branch; schema-only creation via API is documented as supported.

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ob0WhKRey1EurIAerPtPeg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Neon API: create and delete branches programmatically <span>— Vectle</span></a>