Skip to main content
Creates a new repository in your organization, with optional links to an external mirror or fork from an existing repository.

Basic Usage

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

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

With GitHub Sync

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 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",
    "owner": "your-org",
    "name": "source-repo-id",
    "operation": "fork",
    "ref": "main",              // Optional: branch to fork from
    "auth": {
      "token": "JWT_WITH_READ_ACCESS_TO_SOURCE"
    }
  }
}

Request Body

ParameterTypeDescription
default_branchOptionalDefault branch name for the Code Storage repository (defaults to “main”)
base_repoOptionalConfiguration for GitHub sync or forking (see below)

BaseRepo for GitHub Sync

PropertyTypeDescription
providerRequiredSet to "github"
ownerRequiredGitHub organization or username
nameRequiredGitHub repository name
default_branchOptionalGitHub repository’s default branch

BaseRepo for Forking

PropertyTypeDescription
providerRequiredSet to "code" or "code.storage"
ownerRequiredYour organization name
nameRequiredSource repository ID to fork from
operationRequiredSet to "fork"
refOptionalBranch or tag name to fork from
shaOptionalExact commit SHA to fork at (overrides ref)
auth.tokenRequiredJWT 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

{
  "id": "team/project-alpha",
  "created_at": "2024-01-15T10:30:00Z"
}

Error Responses

StatusDescription
401 UnauthorizedInvalid JWT or missing required scope
409 ConflictRepository already exists