Skip to main content
POST
TypeScript

Create an empty repository

Send only repo_name. The new repository uses main as its default branch, or the default_branch that you send. It has no branch until its first commit, so repos.branches.list returns an empty list. The first commit, for example from repos.commits.create, creates the branch that it targets.
The other samples of this page copy a repository with base_repo.

Authorizations

Authorization
string
header
required

JWT bearer token signed with your organization's registered signing key. There is no OAuth authorization server; you mint tokens yourself and the token's scopes claim carries the granted permission scopes. Public scopes: git:read (read repository contents), git:write (write branches, commits, tags, and notes), repo:write (create and manage repositories), org:read (list an organization's repositories). Each operation's security requirement names the scopes it requires. See https://code.storage/docs/getting-started/authentication for how to mint tokens.

Query Parameters

default_branch
string

Deprecated: use the default_branch body field instead. Default branch for the new repository. When the body also has default_branch, the body value wins.

Body

application/json

Create an empty repository, a copy of a Code Storage repository (base_repo), or a repository that syncs from an external Git host (upstream).

Create-repository request body. It supplies the optional repository name, default branch, and Git Sync or fork configuration.

base_repo
object

Code Storage repository to copy once. The new repository keeps no link to it. Do not set it together with upstream.

default_branch
string

Default branch for the new repository. When omitted, a copy takes the default branch of the source, a sync from GitHub takes the default branch of the GitHub repository, and any other repository uses main. An empty repository has no branch until its first commit, and a commit to this name creates the default branch.

Example:

"main"

repo_name
string

Name of the new repository. It can contain a slash.

Example:

"pierre/sdk-documentation"

upstream
object

External Git host to keep syncing from. The link lasts, and the repository can sync again. Do not set it together with base_repo.

Response

The repository already existed, and the request created nothing.

Result of creating a repository, including its repository name.

http_url
string
required
deprecated

Deprecated: use repo_name. Repository name or path, not a full URL.

Example:

"pierre/sdk-documentation"

message
string
required

Human-readable result: the repository was created, or it already exists. The status gives the same result: 201 or 200.

Example:

"Repository 'pierre/sdk-documentation' created"

repo_id
string
required
deprecated

Deprecated: use repo_name. Stable repository identifier.

Example:

"repo_7f2b3d9"

repo_name
string
required

Repository name or path. It can contain a slash. It matches the JWT repo claim.

Example:

"pierre/sdk-documentation"