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

id
string
Repository ID. If not provided, a UUID will be auto-generated. Supports namespacing with / (e.g., team/project-alpha).
defaultBranch
string
Default branch name for the repository. Defaults to main.
baseRepo
object
Configuration for Git Sync or forking from an existing repository. See below for structure.
ttl
string
Token TTL for this invocation in seconds. Defaults to 1 hour when omitted for this call.

BaseRepo for Git Sync

Use this structure to sync with a GitHub repository:
owner
string
required
GitHub repository owner (username or organization).
name
string
required
GitHub repository name.
defaultBranch
string
GitHub repository’s default branch.

BaseRepo for Forking

Use this structure to fork from an existing Code Storage repository:
id
string
required
The source repository ID to fork from.
ref
string
Branch or tag name to fork from. Forks the tip of this ref.
sha
string
Exact commit SHA to fork at. Overrides ref if both are provided.

Response

id
string
The repository identifier
defaultBranch
string
The repository’s default branch name (e.g., main)

BaseRepo for Git Sync

Use this structure to sync with a GitHub repository:
When baseRepo contains owner and name, Code Storage links the repository to an external Git provider for syncing. See the Integrations guide for details.
Generic Git providers such as GitLab, Bitbucket, Gitea, Forgejo, Codeberg, and SourceHut use the same repository creation flow at the HTTP API layer. After creating the repo, configure credentials with Git credentials.

BaseRepo for Forking

Use this structure to fork from an existing Code Storage repository:
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: The returned repository instance also provides methods for managing branches, commits, files, and more. See the other SDK reference pages for details.