Repositories
Create a branch
Make a branch at another branch, a tag or a commit (from; the default branch when left out).
/repos/{owner}/{name}/branchesNeeds the Write role or higher, and the repository’s rules for creating the branch hold. The name may not be taken, and may not be a folder of another branch’s name or hold one (feature cannot sit beside feature/login). To restore a deleted branch, make it again at the commit delete_branch answered with. Returns the new branch and the commit it points to.
The new branch and the commit it points to. from is a branch, a tag or a commit, the default branch when left out; to restore a deleted branch, send the hash that deleting it answered with. Refused with 404 when from names nothing, 409 when the name is taken or is a folder of another branch’s name (or holds one), 422 when it is not a valid branch name, and 403 without the Write role or when the repository’s rules refuse it. See Branches.
- Authentication: Required. Send an access token as
Authorization: Bearer. - MCP tool:
repositorywithactioncreate_branch, and the same inputs - Scope: An access token needs
repo:write.
Path parameters
Section titled “Path parameters”| Name | Type | Required | Description |
|---|---|---|---|
owner |
string | Yes | The workspace that owns the repository. |
name |
string | Yes | The repository’s name. |
Body parameters
Section titled “Body parameters”Send a JSON object. Names are snake_case, as in responses; the camelCase spelling is accepted too.
| Name | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | The new branch’s name, e.g. “feature/login”. |
from |
string | No | The branch, tag or commit to start it from. The default branch when left out. |
Example request
Section titled “Example request”curl -X POST https://api.g1t.sh/repos/flagon-io/hello/branches \ -H "Authorization: Bearer $G1T_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "feature/login", "from": "main" }'Example response
Section titled “Example response”A successful request answers 200 with:
{ "name": "feature/login", "hash": "9f2c4e1b7a3d5c6e8f0a1b2c3d4e5f6a7b8c9d0e"}Errors
Section titled “Errors”A failed request answers with one of these statuses and a body like {"error": {"code": "not_found", "message": "Repository not found."}}. See errors.
| Status | Code | When |
|---|---|---|
| 401 | unauthenticated |
A token is required, or the one sent is not valid. |
| 403 | forbidden |
The token is valid but not allowed to do this, such as a member-only change or an agent token outside its repository. |
| 404 | not_found |
It does not exist, or you cannot see it. |
| 409 | conflict |
The request conflicts with the current state. |
| 422 | invalid |
The input is not valid. message says which field and why. |