# Branch a project

> Branch every computer and database in the project into a new project, all at once.

> Nevia is in early access for selected teams. The CLI installs with `curl -fsSL https://get.nevia.cloud | sh`, and the MCP server is at https://api.nevia.cloud/mcp. A person signs in once in the browser.
> Setup, sign-in and requesting access: [SKILL.md](https://nevia.cloud/SKILL.md). When Nevia fits and when it doesn't: [why.md](https://nevia.cloud/why.md).

> For the complete documentation index, see [llms.txt](https://nevia.cloud/llms.txt). This page's HTML version: https://nevia.cloud/docs/reference/api/projects/branchProject

`POST https://api.nevia.cloud/v1/projects/{prj}/branch`

## Authorization

- `bearerAuth`: HTTP bearer in the Authorization header

Send the token in the `Authorization: Bearer <token>` header. See [Authenticate](https://nevia.cloud/docs/reference/api.md#authenticate).

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `prj` | path | string | yes | Project id: 27 lowercase letters and digits. Match `^[A-Za-z0-9_-]{1,64}$`. |
| `Idempotency-Key` | header | string | yes | Required for this non-idempotent request. Clients generate one key per action and preserve it across transport retries. Within the retained window, repeats return the recorded result and different input with the same key is 409. Keys expire 10 minutes after admission, or 120 seconds after success or terminal failure, whichever is earlier. Reusing an expired key can execute new work. The API tracks at most 100,000 requests across replicas. New keys at capacity receive 429 with Retry-After of 600–630 seconds. Length `1 <= length <= 255`. |

## Request body

Content type: `application/json`

Schema: `ProjectBranchRequest`

Settings for a project branch

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | string | no | Name of the new project, unique in the workspace (default: the source's name with a number). Match `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$`. Length `1 <= length <= 63`. |

## Behavior

Each member is branched as `POST /v1/computers/{cmp}/branch` or `POST /v1/databases/{db}/branch` would branch it. The source project and its members are untouched, and each branch's `parent` names its source.

The new project gets a copy of the source's grants, access keys included, as they are at the time of the branch. Without a `name` it takes the source's name and the next free number, like `agent-evals-1`.

Branching needs edit access to the project, not a workspace admin. It is the one way a project editor creates a project and copies grants, so a collaborator invited to one project can branch a temporary copy of it.

A branch that would take you past the computer and database limit is refused before anything is created. A member that cannot be branched right now fails with its own error while the others are branched. When every branch is ready the response is 201 with the new project. Otherwise it is 202 with a `project.branch` operation on the new project, which finishes when the members' own operations do, and ends `failed` with `error.details.members` holding each failed member's `id` and `error` if any failed.

## Example request

### cURL

```bash
curl -X POST "https://api.nevia.cloud/v1/projects/01ck8y1dm5qqnf88mytnh4m0h4g/branch" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: 8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "agent-evals-try"
  }'
```

### JavaScript

```js
const body = JSON.stringify({
  "name": "agent-evals-try"
})

fetch("https://api.nevia.cloud/v1/projects/01ck8y1dm5qqnf88mytnh4m0h4g/branch", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.TOKEN}`,
    "Idempotency-Key": "8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60"
  },
  body
})
```

### Python

```python
import os
import requests

url = "https://api.nevia.cloud/v1/projects/01ck8y1dm5qqnf88mytnh4m0h4g/branch"
body = """{
  "name": "agent-evals-try"
}"""
response = requests.request("POST", url, data = body, headers = {
  "Content-Type": "application/json", 
  "Authorization": f"Bearer {os.environ['TOKEN']}", 
  "Idempotency-Key": "8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60"
})

print(response.text)
```

## Responses

### 201

The new project, every branch ready.

Content type: `application/json`

Schema: `ProjectResponse`

| Field | Type | Required | Description |
|---|---|---|---|
| `project` | Project | yes | Optional group of computers and databases inside a workspace. |
| `operations` | array<OperationId> | no | Present only when this request schedules asynchronous work. Absent for synchronous responses. |

Example:

```json
{
  "project": {
    "id": "01ck8y1dm5qqnf88mytnh4m0h4g",
    "workspace": "01d4cnjjq40hnnh0nwmkg35nv2h",
    "name": "agent-evals",
    "created_at": "2026-09-10T12:34:56Z",
    "updated_at": "2026-09-10T12:34:56Z"
  },
  "operations": [
    "01d4cnjm89yk0r3xtv80dy0x7by"
  ]
}
```

### 202

The new project, with the `project.branch` operation.

Content type: `application/json`

Schema: `ProjectResponse`

| Field | Type | Required | Description |
|---|---|---|---|
| `project` | Project | yes | Optional group of computers and databases inside a workspace. |
| `operations` | array<OperationId> | no | Present only when this request schedules asynchronous work. Absent for synchronous responses. |

Example:

```json
{
  "project": {
    "id": "01ck8y1dm5qqnf88mytnh4m0h4g",
    "workspace": "01d4cnjjq40hnnh0nwmkg35nv2h",
    "name": "agent-evals",
    "created_at": "2026-09-10T12:34:56Z",
    "updated_at": "2026-09-10T12:34:56Z"
  },
  "operations": [
    "01d4cnjm89yk0r3xtv80dy0x7by"
  ]
}
```

### 400

`validation_failed`: malformed body, unknown field, or invalid id or name. Fix `details.field` and retry.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `validation_failed`:

```json
{
  "error": {
    "code": "validation_failed",
    "message": "Unknown field `colour` in the request body. Remove it; request bodies are strict.",
    "details": {
      "field": "colour",
      "in": "body"
    }
  }
}
```

### 401

`unauthorized`: the credential is missing, malformed, expired, or revoked. Send a valid bearer token.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `unauthorized`:

```json
{
  "error": {
    "code": "unauthorized",
    "message": "Missing credential. Send `Authorization: Bearer <token>` with an access token.",
    "details": {}
  }
}
```

### 403

`forbidden`: the token is read-only or scoped elsewhere, or the role cannot do this. Use a token or role that allows it.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `forbidden`:

```json
{
  "error": {
    "code": "forbidden",
    "message": "You can view computer 01d4cnjk3xg90y576w8y6t4gdwm but your role does not allow computer#edit. Ask a workspace admin to change your role (PATCH /v1/workspaces/{ws}/access/{principal}).",
    "details": {
      "computer": "01d4cnjk3xg90y576w8y6t4gdwm",
      "permission": "computer#edit"
    }
  }
}
```

### 404

`not_found`: the project does not exist, or you cannot see it. Both return the same response.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `not_found`:

```json
{
  "error": {
    "code": "not_found",
    "message": "Project 01ck8y1dm5qqnf88mytnh4m0h4g was not found. List the projects you can access with GET /v1/projects?workspace=<ws>.",
    "details": {
      "project": "01ck8y1dm5qqnf88mytnh4m0h4g"
    }
  }
}
```

### 409

`name_conflict`: the workspace already has a project with the requested name. `limit_exceeded`: branching every member would pass the beta cap on live computers and databases. `idempotency_conflict`: the `Idempotency-Key` was already used with a different body.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `name_conflict`:

```json
{
  "error": {
    "code": "name_conflict",
    "message": "Workspace 01d4cnjjq40hnnh0nwmkg35nv2h already has a project named agent-evals-1. Pick another name.",
    "details": {
      "workspace": "01d4cnjjq40hnnh0nwmkg35nv2h",
      "name": "agent-evals-1"
    }
  }
}
```

Example `limit_exceeded`:

```json
{
  "error": {
    "code": "limit_exceeded",
    "message": "Beta limit reached: 19 of 20 computers and databases across your workspaces, and this needs 3 more. Delete a computer or database, or request more capacity: https://console.nevia.cloud/settings#plan",
    "details": {
      "kind": "project",
      "scope": "user",
      "count": 19,
      "limit": 20,
      "computers": 13,
      "databases": 6,
      "upgrade_url": "https://console.nevia.cloud/settings#plan"
    }
  }
}
```

Example `idempotency_conflict`:

```json
{
  "error": {
    "code": "idempotency_conflict",
    "message": "Idempotency-Key 8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60 was already used for a different POST /v1/projects/{prj}/branch request. Use a new key for a new request.",
    "details": {
      "idempotency_key": "8f1c2a7e-3b4d-4c5e-9f0a-1b2c3d4e5f60"
    }
  }
}
```

### 429

`rate_limited`: slow down. Retry after `Retry-After`.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `rate_limited`:

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests. Retry after 2 seconds.",
    "details": {
      "retry_after_seconds": 2
    }
  }
}
```

### 500

`request_failed`: the request failed for a reason with no code of its own. The diagnostic stays in server logs. `branch_failed`: the new project could not be linked, and it was removed. Nothing was created. `branch_failed`: linking the new project had an unknown outcome. No branch was made, and the project in `details.branch` stays. Delete it before branching again. `branch_failed`: the source's grants could not all be copied. The new project in `details.branch` stays, with none of the branches. Delete it before branching again.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `request_failed`:

```json
{
  "error": {
    "code": "request_failed",
    "message": "request failed",
    "details": {}
  }
}
```

Example `branch_failed: the new project could not be linked, and it was removed. Nothing was created`:

```json
{
  "error": {
    "code": "branch_failed",
    "message": "Project 01ck8y1dm5qqnf88mytnh4m0h4g could not be branched.",
    "details": {
      "project": "01ck8y1dm5qqnf88mytnh4m0h4g"
    }
  }
}
```

Example `branch_failed: linking the new project had an unknown outcome. No branch was made, and the project in \`details.branch\` stays. Delete it before branching again`:

```json
{
  "error": {
    "code": "branch_failed",
    "message": "Project 01ck8y1dm5qqnf88mytnh4m0h4g could not be branched: project 01d4cnjjq40hnnh0nwmkg35nv2h was kept with none of the branches. Delete it before branching again.",
    "details": {
      "project": "01ck8y1dm5qqnf88mytnh4m0h4g",
      "branch": "01d4cnjjq40hnnh0nwmkg35nv2h"
    }
  }
}
```

Example `branch_failed: the source's grants could not all be copied. The new project in \`details.branch\` stays, with none of the branches. Delete it before branching again`:

```json
{
  "error": {
    "code": "branch_failed",
    "message": "Project 01ck8y1dm5qqnf88mytnh4m0h4g could not be branched: project 01d4cnjjq40hnnh0nwmkg35nv2h was created, but with none of the branches and without all of its grants. Delete it before branching again.",
    "details": {
      "project": "01ck8y1dm5qqnf88mytnh4m0h4g",
      "branch": "01d4cnjjq40hnnh0nwmkg35nv2h"
    }
  }
}
```

### 503

The action is temporarily unavailable, named by its code (`creation_failed`, `wake_failed`, ...). Wait at least `Retry-After` seconds (60 by default). `details.retryable` says whether repeating the request is safe. Keep the original `Idempotency-Key`. Signing in again does not help.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `creation_failed`:

```json
{
  "error": {
    "code": "creation_failed",
    "message": "The computer could not be created. Try again later.",
    "details": {
      "retryable": true
    }
  }
}
```
