Skip to main content
// Basic repository creation (defaults to 'main' branch)
const repo = await store.createRepo();

// With custom ID
const repo = await store.createRepo({
  id: "my-custom-repo",
});

// With custom default branch
const repo = await store.createRepo({
  id: "my-custom-repo",
  defaultBranch: "develop",
});

// With namespacing
const repo = await store.createRepo({
  id: "production/api-service",
  defaultBranch: "production",
});

// Fork from existing repository
const fork = await store.createRepo({
  id: "my-fork",
  baseRepo: {
    id: "source-repo",       // Repository to fork from
    ref: "main",             // Optional: branch to fork from
  },
});

Options

ParameterTypeDescription
idOptionalRepository ID. If not provided, a UUID will be auto-generated. Supports namespacing with / (e.g., team/project-alpha).
defaultBranch (TypeScript)
default_branch (Python)
OptionalDefault branch name for the repository. Defaults to main.
baseRepo (TypeScript)
base_repo (Python)
OptionalConfiguration for GitHub sync or forking from an existing repository. See below for structure.
ttlOptionalToken TTL in seconds for this invocation. Defaults to 3600 (1 hour).

BaseRepo for GitHub Sync

Use this structure to sync with a GitHub repository:
PropertyTypeDescription
ownerRequiredGitHub repository owner (username or organization).
nameRequiredGitHub repository name.
defaultBranch (TypeScript)
default_branch (Python)
OptionalGitHub repository’s default branch.
When baseRepo contains owner and name, Code Storage links the repository to GitHub for automatic syncing. See the GitHub Sync guide for details.

BaseRepo for Forking

Use this structure to fork from an existing Code Storage repository:
PropertyTypeDescription
idRequiredThe source repository ID to fork from.
refOptionalBranch or tag name to fork from. Forks the tip of this ref.
shaOptionalExact commit SHA to fork at. Overrides ref if both are provided.
When baseRepo contains id, a fork is created from the specified repository. See the Forking guide for details.

Response

Returns a Repository instance with the following properties:
PropertyTypeDescription
idStringThe repository identifier
defaultBranch (TypeScript)
default_branch (Python)
StringThe repository’s default branch name (e.g., main)
The returned repository instance also provides methods for managing branches, commits, files, and more. See the other SDK reference pages for details.