---
title: "Create a new branch"
method: POST
path: "/api/repos/{namespace}/{repo_name}/branches"
tags: ["Branches"]
---

# Create a new branch

`POST /api/repos/{namespace}/{repo_name}/branches`

## Request

- Base URL: `https://hub.oxen.ai`
- URL: `https://hub.oxen.ai/api/repos/{namespace}/{repo_name}/branches`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/oxen/apis/oxen-server/docs/api/repos/:namespace/:repo_name/branches/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a new branch from another branch name or commit ID. Returns existing branch if name already exists.

## Path parameters

- `namespace` string, required
- `repo_name` string, required

## Request body

- BranchNewFromBranchName
  - `from_name` string, required
  - `new_name` string, required

## Response `200`

Branch created

- BranchResponse
  - `oxen_version` string, nullable
  - `status` string, required
  - `status_message` string, required
  - `branch` Branch, required
    - `commit_id` string, required
    - `name` string, required

## Other responses

- `400`: Invalid request body
- `404`: Repository or source branch/commit not found

---

[API](https://skmtc.dev/oxen/apis/oxen-server.md) - [All operations](https://skmtc.dev/oxen/apis/oxen-server/llms.txt) - [OpenAPI document](https://skmtc.dev/oxen/apis/oxen-server/revisions/2ae578129949?raw)
