---
title: "Create a branch given a project, the base git ref, and the new branch's name"
method: POST
path: "/spaces/{spaceIdentifier}/projects/{projectId}/git/branches/v2"
tags: ["Branches"]
---

# Create a branch given a project, the base git ref, and the new branch's name

`POST /spaces/{spaceIdentifier}/projects/{projectId}/git/branches/v2`

## Path parameters

- `spaceIdentifier` string, required
- `projectId` string, required

## Request body

- CreateBranchCommandV2
  - `BaseGitRef` string, required
  - `NewBranchName` string, required
  - `ProjectId` string, required
  - `SpaceId` string, required — The ID of the space containing the resource(s).

## Response `200`

The newly-created Branch

- GitBranchResource
  - `CanonicalName` string, required
  - `Id` string — Gets or sets a unique identifier for this resource.
  - `IsProtected` boolean, required
  - `LastModifiedBy` string — Gets or sets the username of the user who last modified this resource.
  - `LastModifiedOn` string, date-time — Gets or sets the date/time that this resource was last modified.
  - `Links` object — Gets or sets a dictionary of links to other related resources. These links can be used to navigate the resources on the server.
  - `Name` string, required

## Other responses

- `400` — Bad request. Either the payload was not structurally valid or business rules did not permit the operation.
- `404` — Not found. One or more of the entities involved in the operation was not found.

---

[API](https://skmtc.net/octopus/apis/octopus-server-api.md) · [All operations](https://skmtc.net/octopus/apis/octopus-server-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/octopus/octopus-server-api/revisions/b296c3a60aa5/schema)
