Skip to main content
const branch = await repo.createBranch({
  baseBranch: "main", // source branch
  targetBranch: "feature/new-onboarding",
  // baseIsEphemeral: true,
  // targetIsEphemeral: true,
});

console.log(branch.targetBranch); // 'feature/new-onboarding'
console.log(branch.commitSha); // tip SHA when available
Toggle baseIsEphemeral/targetIsEphemeral to work with ephemeral refs. The method returns the API message plus the resolved branch metadata so you can confirm creation before pushing commits.

Options

ParameterTypeDescription
baseBranchRequiredSource branch to copy from. Combine with baseIsEphemeral when promoting from the ephemeral namespace.
targetBranchRequiredDestination branch name. May match baseBranch when moving between namespaces.
baseIsEphemeralOptionaltrue when the source branch lives in the ephemeral namespace (defaults to false).
targetIsEphemeralOptionaltrue to create/update an ephemeral branch instead of the default namespace.
See the Ephemeral Branches guide for concrete promotion examples using these flags.

Response

FieldTypeDescription
messageStringConfirmation message
targetBranch (TypeScript)
target_branch (Python)
StringThe created branch name
targetIsEphemeral (TypeScript)
target_is_ephemeral (Python)
BooleanWhether the branch is in the ephemeral namespace
commitSha (TypeScript)
commit_sha (Python)
OptionalThe tip commit SHA of the new branch