---
title: "Create a branch on the server, off main by default"
description: "Points a new branch at `from` (default: main's head) with no new\ncommit. The caller becomes the branch's author. 409 `branch_exists` if\nit exists. The answer has `stale: true` until the branch's facts are\ncomputed (a `branch.updated` event follows).\n"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.gitpando.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Pando API › branches

`POST /v1/monorepos/{owner}/{monorepo}/repos/{repo}/branches`

Points a new branch at `from` (default: main's head) with no new
commit. The caller becomes the branch's author. 409 `branch_exists` if
it exists. The answer has `stale: true` until the branch's facts are
computed (a `branch.updated` event follows).

## Authentication

Requires one of the following:

- `credential`, http, header `Authorization`
- `session`, apiKey, in cookie

## Path parameters

- `createBranch.path.owner` (string, required) — The monorepo's owner, a namespace (a person's login or an organization). Matched without case.
  - pattern `^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$`
- `createBranch.path.monorepo` (string, required) — The monorepo's name within its owner (or an old name). Matched without case.
  - pattern `^[a-z0-9](?:[a-z0-9._]|-(?!-)){0,38}$`
- `createBranch.path.repo` (string, required) — The repo's `name` (`projects-web`).

## Request body

_Required._

- `createBranch.name` (string, required) — A git branch name, for example `agent-3/oauth`. Not the default branch.
- `createBranch.from` (string, optional) — A branch name or a full sha. Default: the default branch.
- `createBranch.title` (string, optional)
- `createBranch.description` (string, optional)

## Example request

```json
{
  "name": "string",
  "from": "string",
  "title": "string",
  "description": "string"
}
```

## Code samples

### cURL

```curl
curl --request POST \
  --url https://app.gitpando.com/v1/monorepos/string/string/repos/string/branches \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "string",
  "from": "string",
  "title": "string",
  "description": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://app.gitpando.com/v1/monorepos/string/string/repos/string/branches';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({name: 'string', from: 'string', title: 'string', description: 'string'})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://app.gitpando.com/v1/monorepos/string/string/repos/string/branches"

payload = {
    "name": "string",
    "from": "string",
    "title": "string",
    "description": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Created

#### Example

```json
{
  "name": "string",
  "head": "string",
  "base": "string",
  "author": "string",
  "title": "string",
  "description": "string",
  "ahead": 0,
  "behind": 0,
  "mergeable": "clean",
  "stale": true,
  "last_mergeable": "string",
  "conflict_paths": [
    "string"
  ],
  "facts_at": "2019-08-24T14:15:22Z",
  "checks": {
    "sha": "string",
    "state": "success",
    "required": [
      "string"
    ],
    "checks_unknown": "string",
    "missing": [
      "string"
    ],
    "statuses": [
      {
        "sha": "string",
        "context": "string",
        "state": "pending",
        "target_url": "string",
        "description": "string",
        "creator": "string",
        "app": "string",
        "created_at": "2019-08-24T14:15:22Z"
      }
    ]
  },
  "state": "open",
  "merge_commit": "string",
  "merged_by": "string",
  "merged_at": "2019-08-24T14:15:22Z",
  "merged_machine": "string",
  "merged_agent": "string",
  "pushed_machine": "string",
  "forced": true,
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z"
}
```

- `createBranch.response.201.name` (string, required)
- `createBranch.response.201.head` (string, required)
- `createBranch.response.201.checks` (object, required) — GitHub's combined status, plus the required contexts and which are missing.
  - `createBranch.response.201.checks.sha` (string | null, required)
  - `createBranch.response.201.checks.state` (string, required) — `success` when the merge gate passes; `missing` when a required context has not reported; `unknown` while the required checks are (an unforced merge is refused).
    - one of `"success"`, `"pending"`, `"failure"`, `"error"`, `"missing"`, `"unknown"`
  - `createBranch.response.201.checks.required` (array | null, required) — Null while unknown.
  - `createBranch.response.201.checks.checks_unknown` (string | null, required) — Why the required checks are unknown, in plain words: "Pando couldn't read this monorepo's required checks; try again", or "pando.toml line 3: expected comma or end of structure; fix it on main, or merge with force". Null otherwise.
  - `createBranch.response.201.checks.statuses` (array<object>, required) — The latest status per context.
    - `createBranch.response.201.checks.statuses.sha` (string, required)
    - `createBranch.response.201.checks.statuses.context` (string, required)
    - `createBranch.response.201.checks.statuses.state` (string, required)
      - one of `"pending"`, `"success"`, `"failure"`, `"error"`
    - `createBranch.response.201.checks.statuses.created_at` (string, required)
      - format `date-time`
    - `createBranch.response.201.checks.statuses.target_url` (string | null, optional)
    - `createBranch.response.201.checks.statuses.description` (string | null, optional)
    - `createBranch.response.201.checks.statuses.creator` (string, optional) — The member who posted it (a login); `app:<slug>` for a status posted with a status token or by a CI integration; `hook:<hook id>` for a status token from a web hook with no app.
    - `createBranch.response.201.checks.statuses.app` (string | null, optional) — The CI service that reported it (`buildkite`, `github-actions`, ...), stamped by Pando from a status token or a CI integration, never from the body or `target_url`. Null when a member posted it with their own credential. The web shows the service's mark for a slug it knows.
  - `createBranch.response.201.checks.missing` (array<string>, optional)
- `createBranch.response.201.state` (string, required) — `merged` when the branch's current head was landed by a Pando merge.
  - one of `"open"`, `"merged"`
- `createBranch.response.201.base` (string | null, optional) — The merge base with the default branch; null when there is none.
- `createBranch.response.201.author` (string | null, optional) — The user whose first push (or createBranch) made the branch.
- `createBranch.response.201.title` (string | null, optional)
- `createBranch.response.201.description` (string | null, optional)
- `createBranch.response.201.ahead` (integer | null, optional) — Commits on the branch that are not on the default branch.
- `createBranch.response.201.behind` (integer | null, optional) — Commits on the default branch that are not on the branch.
- `createBranch.response.201.mergeable` (string, optional) — From the merge engine's dry run. `up_to_date`: the branch adds nothing. `pending`: not yet computed for the current main and head (see `last_mergeable`).
  - one of `"clean"`, `"conflicts"`, `"up_to_date"`, `"unknown"`, `"pending"`
- `createBranch.response.201.stale` (boolean, optional) — True while ahead, behind, base and mergeable are not yet for the current main and head.
- `createBranch.response.201.last_mergeable` (string | null, optional) — When stale: the last known mergeable answer.
- `createBranch.response.201.conflict_paths` (array | null, optional) — The paths changed differently on both sides, from the same dry run as `mergeable` (or `last_mergeable` while stale), so a branch page shows them before Merge is pressed. Null unless that answer is `conflicts`. No cap: the same list a refused merge's 409 carries in `paths`.
- `createBranch.response.201.facts_at` (string | null, optional) — When the facts were computed.
  - format `date-time`
- `createBranch.response.201.merge_commit` (string | null, optional)
- `createBranch.response.201.merged_by` (string | null, optional) — The user who merged (state merged only).
- `createBranch.response.201.merged_at` (string | null, optional)
  - format `date-time`
- `createBranch.response.201.merged_machine` (string | null, optional) — The name of the credential used to merge: the machine or sandbox.
- `createBranch.response.201.merged_agent` (string | null, optional) — The agent that merged, from X-Pando-Agent, if one said so.
- `createBranch.response.201.pushed_machine` (string | null, optional) — The name of the credential that last pushed the branch: the machine or sandbox.
- `createBranch.response.201.forced` (boolean | null, optional) — True when the merge went past red or missing checks with force=1.
- `createBranch.response.201.created_at` (string | null, optional)
  - format `date-time`
- `createBranch.response.201.updated_at` (string | null, optional)
  - format `date-time`

### 409

An error

#### Example

```json
{
  "error": {
    "code": "string",
    "message": "string",
    "paths": [
      "string"
    ],
    "checks": {
      "sha": "string",
      "state": "success",
      "required": [
        "string"
      ],
      "checks_unknown": "string",
      "missing": [
        "string"
      ],
      "statuses": [
        {
          "sha": "string",
          "context": "string",
          "state": "pending",
          "target_url": "string",
          "description": "string",
          "creator": "string",
          "app": "string",
          "created_at": "2019-08-24T14:15:22Z"
        }
      ]
    }
  }
}
```

- `createBranch.response.409.error` (object, required)
  - `createBranch.response.409.error.code` (string, required)
  - `createBranch.response.409.error.message` (string, required)
  - `createBranch.response.409.error.paths` (array<string>, optional)
  - `createBranch.response.409.error.checks` (object, optional) — GitHub's combined status, plus the required contexts and which are missing.
    - `createBranch.response.409.error.checks.sha` (string | null, required)
    - `createBranch.response.409.error.checks.state` (string, required) — `success` when the merge gate passes; `missing` when a required context has not reported; `unknown` while the required checks are (an unforced merge is refused).
      - one of `"success"`, `"pending"`, `"failure"`, `"error"`, `"missing"`, `"unknown"`
    - `createBranch.response.409.error.checks.required` (array | null, required) — Null while unknown.
    - `createBranch.response.409.error.checks.checks_unknown` (string | null, required) — Why the required checks are unknown, in plain words: "Pando couldn't read this monorepo's required checks; try again", or "pando.toml line 3: expected comma or end of structure; fix it on main, or merge with force". Null otherwise.
    - `createBranch.response.409.error.checks.statuses` (array<object>, required) — The latest status per context.
      - `createBranch.response.409.error.checks.statuses.sha` (string, required)
      - `createBranch.response.409.error.checks.statuses.context` (string, required)
      - `createBranch.response.409.error.checks.statuses.state` (string, required)
        - one of `"pending"`, `"success"`, `"failure"`, `"error"`
      - `createBranch.response.409.error.checks.statuses.created_at` (string, required)
        - format `date-time`
      - `createBranch.response.409.error.checks.statuses.target_url` (string | null, optional)
      - `createBranch.response.409.error.checks.statuses.description` (string | null, optional)
      - `createBranch.response.409.error.checks.statuses.creator` (string, optional) — The member who posted it (a login); `app:<slug>` for a status posted with a status token or by a CI integration; `hook:<hook id>` for a status token from a web hook with no app.
      - `createBranch.response.409.error.checks.statuses.app` (string | null, optional) — The CI service that reported it (`buildkite`, `github-actions`, ...), stamped by Pando from a status token or a CI integration, never from the body or `target_url`. Null when a member posted it with their own credential. The web shows the service's mark for a slug it knows.
    - `createBranch.response.409.error.checks.missing` (array<string>, optional)

### 503

`repo_busy`: the repo's write slots stayed taken for 120 s.

#### Example

```json
{
  "error": {
    "code": "string",
    "message": "string",
    "paths": [
      "string"
    ],
    "checks": {
      "sha": "string",
      "state": "success",
      "required": [
        "string"
      ],
      "checks_unknown": "string",
      "missing": [
        "string"
      ],
      "statuses": [
        {
          "sha": "string",
          "context": "string",
          "state": "pending",
          "target_url": "string",
          "description": "string",
          "creator": "string",
          "app": "string",
          "created_at": "2019-08-24T14:15:22Z"
        }
      ]
    }
  }
}
```

- `createBranch.response.503.error` (object, required)
  - `createBranch.response.503.error.code` (string, required)
  - `createBranch.response.503.error.message` (string, required)
  - `createBranch.response.503.error.paths` (array<string>, optional)
  - `createBranch.response.503.error.checks` (object, optional) — GitHub's combined status, plus the required contexts and which are missing.
    - `createBranch.response.503.error.checks.sha` (string | null, required)
    - `createBranch.response.503.error.checks.state` (string, required) — `success` when the merge gate passes; `missing` when a required context has not reported; `unknown` while the required checks are (an unforced merge is refused).
      - one of `"success"`, `"pending"`, `"failure"`, `"error"`, `"missing"`, `"unknown"`
    - `createBranch.response.503.error.checks.required` (array | null, required) — Null while unknown.
    - `createBranch.response.503.error.checks.checks_unknown` (string | null, required) — Why the required checks are unknown, in plain words: "Pando couldn't read this monorepo's required checks; try again", or "pando.toml line 3: expected comma or end of structure; fix it on main, or merge with force". Null otherwise.
    - `createBranch.response.503.error.checks.statuses` (array<object>, required) — The latest status per context.
      - `createBranch.response.503.error.checks.statuses.sha` (string, required)
      - `createBranch.response.503.error.checks.statuses.context` (string, required)
      - `createBranch.response.503.error.checks.statuses.state` (string, required)
        - one of `"pending"`, `"success"`, `"failure"`, `"error"`
      - `createBranch.response.503.error.checks.statuses.created_at` (string, required)
        - format `date-time`
      - `createBranch.response.503.error.checks.statuses.target_url` (string | null, optional)
      - `createBranch.response.503.error.checks.statuses.description` (string | null, optional)
      - `createBranch.response.503.error.checks.statuses.creator` (string, optional) — The member who posted it (a login); `app:<slug>` for a status posted with a status token or by a CI integration; `hook:<hook id>` for a status token from a web hook with no app.
      - `createBranch.response.503.error.checks.statuses.app` (string | null, optional) — The CI service that reported it (`buildkite`, `github-actions`, ...), stamped by Pando from a status token or a CI integration, never from the body or `target_url`. Null when a member posted it with their own credential. The web shows the service's mark for a slug it knows.
    - `createBranch.response.503.error.checks.missing` (array<string>, optional)


Source: https://docs.gitpando.com/api/branches/createBranch/index.md
