Skip to content
  • Auto
  • Light
  • Dark

Create

Create a new branch for a project
client.projects.branches.create(BranchCreateParamsparams, RequestOptionsoptions?): branchstringconfig_commitCommitlatest_buildunionobject"project_branch"orgstringprojectstringProjectBranch
post/v0/projects/{project}/branches

Create a new branch for a project

Parameters
paramsprojectstringbranchstringbranch_fromstringforcebooleanBranchCreateParams
Hide ParametersShow Parameters
projectstring
optional

Path param:

branchstring

Body param: Name of the new project branch.

branch_fromstring

Body param: Branch or commit SHA to branch from.

forceboolean
optional

Body param: Whether to throw an error if the branch already exists. Defaults to false.

Returns
branchstringconfig_commitCommitlatest_buildunionobject"project_branch"orgstringprojectstringProjectBranch
import Stainless from '@stainless-api/sdk';

const client = new Stainless({
  apiKey: 'My API Key',
});

const projectBranch = await client.projects.branches.create({
  project: 'project',
  branch: 'branch',
  branch_from: 'branch_from',
});

console.log(projectBranch.branch);
200 Example
{
  "branch": "branch",
  "config_commit": {
    "repo": {
      "branch": "branch",
      "name": "name",
      "owner": "owner"
    },
    "sha": "sha"
  },
  "latest_build": {
    "id": "id",
    "config_commit": "config_commit",
    "created_at": "2019-12-27T18:11:19.117Z",
    "documented_spec": {
      "content": "content",
      "type": "content"
    },
    "object": "build",
    "org": "org",
    "project": "project",
    "targets": {
      "cli": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "csharp": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "go": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "java": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "kotlin": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "node": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "php": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "python": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "ruby": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "terraform": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      },
      "typescript": {
        "commit": {
          "status": "not_started"
        },
        "lint": {
          "status": "not_started"
        },
        "object": "build_target",
        "status": "not_started",
        "test": {
          "status": "not_started"
        },
        "build": {
          "status": "not_started"
        },
        "upload": {
          "status": "not_started"
        }
      }
    },
    "updated_at": "2019-12-27T18:11:19.117Z"
  },
  "object": "project_branch",
  "org": "org",
  "project": "project"
}