Skip to main content
Creates a new repository in your organization, with optional links to an external mirror or fork from an existing repository. The repository identifier is taken from the JWT repo claim (not the request body).

Basic Usage

POST /api/v1/repos
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "default_branch": "main"  // Optional, defaults to "main"
}

With Git Sync (GitHub)

POST /api/v1/repos
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "default_branch": "main",
  "base_repo": {
    "provider": "github",
    "owner": "org-name",
    "name": "repo-name",
    "default_branch": "main"
  }
}

With Git Sync (generic HTTPS Git)

POST /api/v1/repos
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "default_branch": "main",
  "base_repo": {
    "provider": "gitlab",
    "owner": "group-name",
    "name": "repo-name",
    "default_branch": "main"
  }
}
For self-hosted providers, and for providers without a fixed public host such as gitea and forgejo, pass upstream_host:
POST /api/v1/repos
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "default_branch": "main",
  "base_repo": {
    "provider": "gitea",
    "owner": "org-name",
    "name": "repo-name",
    "default_branch": "main",
    "upstream_host": "git.example.com"
  }
}
After creating a generic Git Sync repository, store credentials with Git credentials.

With Forking

Fork from an existing Code Storage repository:
POST /api/v1/repos
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: application/json

{
  "base_repo": {
    "provider": "code.storage",
    "name": "source-repo",
    "operation": "fork",
    "ref": "main",              // Optional: branch to fork from
    "auth": {
      "token": "JWT_WITH_READ_ACCESS_TO_SOURCE"
    }
  }
}

Request Body

default_branch
string
Default branch name for the Code Storage repository (defaults to “main”)
base_repo
object
Configuration for Git Sync or forking. When omitted, Code Storage creates an empty repository.

BaseRepo for Git Sync

provider
string
required
Set to one of github, gitlab, bitbucket, gitea, forgejo, codeberg, sr.ht, or sourcehut.
owner
string
required
Repository owner, namespace, or account name for the external provider.
name
string
required
External repository name.
default_branch
string
Upstream repository default branch.
operation
string
Sync mode operation. Defaults to "sync" when omitted.
upstream_host
string
Bare hostname for self-hosted providers, such as git.example.com. Required when the provider has no built-in default host.
auth.auth_type
string
For GitHub only, set to "public" to use unauthenticated public GitHub access.

BaseRepo for Forking

provider
string
required
Set to "code" or "code.storage"
owner
string
Ignored for code.storage providers
name
string
required
Source repository URL (name) to fork from
operation
string
required
Set to "fork"
ref
string
Branch or tag name to fork from
sha
string
Exact commit SHA to fork at (overrides ref)
auth.token
string
required
JWT with git:read scope for the source repository

JWT Requirements

  • Requires the repo:write scope for the new repository
  • For forking, base_repo.auth.token must have git:read scope for the source repository

Response

{
  "repo_id": "V1StGXR8_Z5jdHi6B-myT",
  "http_url": "team/project-alpha",
  "message": "Repository 'V1StGXR8_Z5jdHi6B-myT' created successfully"
}

Error Responses

401 Unauthorized
string
Invalid JWT or missing required scope
409 Conflict
string
Repository already exists or already has an upstream configured
412 Precondition Failed
string
GitHub App configuration is required for authenticated GitHub sync