# Create a branch

**POST** `/v1/projects/{projectId}/branches`

⚠️ Experimental endpoint: this API is in active development and may change at any time without notice. ⚠️

Creates a Branch under the specified Project. The first Branch in a Project is always created with isDefault=true and role=production regardless of the body value. Later Branches are created with role=preview. Setting isDefault=true while another Branch already holds the default atomically swaps the default flag only.

Base URL: `https://api.prisma.io`

Tags: `[Experimental]`

## Authorization

Any ONE of the following options authorizes this operation; every scheme listed within an option is required together.

| Option | Scheme | Type | Sent as | Scopes |
| --- | --- | --- | --- | --- |
| Option 1 | `OAuth2` | `oauth2` | `Authorization: Bearer <access token>` | `offline_access`, `workspace:admin` |
| Option 2 | `Bearer` | `http` | `Authorization: Bearer <token>` (JWT) | — |

### OAuth 2.0 flows

- **OAuth2 · authorizationCode**
  - Authorization URL: `https://auth.prisma.io/authorize`
  - Token URL: `https://auth.prisma.io/token`
  - Refresh URL: `https://auth.prisma.io/token`
  - Scope `offline_access` — Offline access
  - Scope `workspace:admin` — Full access to workspace resources

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `projectId` | `string` | Yes | — |

## Request body

Optional. Media type: `application/json`

### Example request body

```json
{
  "gitName": "string",
  "isDefault": true
}
```

## Responses

| Status | Description | Media type |
| --- | --- | --- |
| `201` | Created the Branch. | `application/json` |
| `401` | Missing or invalid authorization token. | `application/json` |
| `404` | Project not found. | `application/json` |
| `409` | A live Branch with the same gitName already exists. | `application/json` |
| `422` | Invalid gitName. | `application/json` |

### Example response: 201 — Created the Branch.

```json
{
  "data": {
    "createdAt": "2026-06-09T00:00:00Z",
    "gitName": "string",
    "id": "string",
    "isDefault": true,
    "project": {
      "id": "string",
      "name": "string",
      "url": "https://example.com"
    },
    "role": "preview",
    "type": "branch",
    "updatedAt": "2026-06-09T00:00:00Z",
    "url": "https://example.com"
  }
}
```

### Example response: 401 — Missing or invalid authorization token.

```json
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
```

### Example response: 404 — Project not found.

```json
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
```

### Example response: 409 — A live Branch with the same gitName already exists.

```json
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
```

### Example response: 422 — Invalid gitName.

```json
{
  "error": {
    "code": "string",
    "hint": "string",
    "message": "string"
  }
}
```

## Related pages

- [[Experimental]](./tags/experimental.md)
- [Acquire Alchemy deploy lease](./postv1projectsbyprojectidbranchesbybranchidalchemy-statelease.md)
- [Agents](./tags/agents.md)
- [Alchemy state store version](./getv1projectsbyprojectidbranchesbybranchidalchemy-stateversion.md)
- [Buckets](./tags/buckets.md)
- [Connections](./tags/connections.md)
- [Create a custom domain](./postv1appsbyappiddomains.md)
- [Create a custom domain](./postv1servicesbyserviceiddomains.md)
- [Create a workspace](./postv1workspaces.md)
- [Create an environment variable](./postv1environment-variables.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
