# Create

Launch stage: GA

`POST /api/2.0/repos`

Creates a repo in the workspace and links it to the remote Git repo specified. 
 Note that repos created programmatically must be linked to a remote Git repo, unlike repos
 created in the browser.

API scopes: workspace

## Request body

- `url` (string, optional)
  URL of the Git repository to be linked.
  Example: `https://github.com/databricks/cli.git`
- `provider` (string, optional)
  Git provider. This field is case-insensitive. The available Git providers are `gitHub`,
   `bitbucketCloud`, `gitLab`, `azureDevOpsServices` (Azure DevOps Services, including
   Microsoft Entra ID authentication), `gitHubEnterprise`, `bitbucketServer` (Bitbucket
   Data Center), `gitLabEnterpriseEdition` (GitLab Self-Managed), and `awsCodeCommit`.
  Example: `gitHub`
- `path` (string, optional)
  Desired path for the repo in the workspace. Almost any path in the workspace can be chosen.
   If repo is created in `/Repos`, path must be in the format `/Repos/{folder}/{repo-name}`.
  Example: `/Users/user@company.com/testrepo`
- `sparse_checkout` (object, optional)
  If specified, the repo will be created with sparse checkout enabled. You cannot enable/disable
   sparse checkout after the repo is created.
  - `patterns` (array of string, optional)
    List of sparse checkout cone patterns, see
     [cone mode handling](https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling)
     for details.
- `git_credential_id` (int64, optional)
  Git credential ID to use when cloning the repository. The Git credential must be
   configured for the current user.

## Returns

- `id` (int64, optional)
  ID of the Git folder (repo) object in the workspace.
- `path` (string, optional)
  Path of the Git folder (repo) in the workspace.
  Example: `/Users/user@company.com/testrepo`
- `url` (string, optional)
  URL of the linked Git repository.
  Example: `https://github.com/databricks/cli.git`
- `provider` (string, optional)
  Git provider of the linked Git repository, e.g. `gitHub`, `azureDevOpsServices`,
   `bitbucketServer` (Bitbucket Data Center), `gitLabEnterpriseEdition` (GitLab
   Self-Managed), or `awsCodeCommit`.
  Example: `gitHub`
- `branch` (string, optional)
  Branch that the Git folder (repo) is checked out to.
  Example: `main`
- `head_commit_id` (string, optional)
  SHA-1 hash representing the commit ID of the current HEAD of the Git folder (repo).
  Example: `7e0847ede61f07adede22e2bcce6050216489171`
- `sparse_checkout` (object, optional)
  Sparse checkout settings for the Git folder (repo).
  - `patterns` (array of string, optional)
    List of sparse checkout cone patterns, see
     [cone mode handling](https://git-scm.com/docs/git-sparse-checkout#_internalscone_mode_handling)
     for details.

## Request

```json
{
  "branch": "main",
  "path": "/Users/user@company.com/clitest",
  "provider": "gitHub",
  "sparse_checkout": {
    "patterns": [
      "parent-folder/child-folder",
      "src",
      "test"
    ]
  },
  "url": "https://github.com/databricks/cli.git"
}
```

## Response

### The Git folder (repo) was successfully created.

```json
{
  "branch": "main",
  "head_commit_id": "7e0847ede61f07adede22e2bcce6050216489171",
  "id": "5249608814509279",
  "path": "/Users/user@company.com/clitest",
  "provider": "gitHub",
  "sparse_checkout": {
    "patterns": [
      "parent-folder/child-folder",
      "src",
      "test"
    ]
  },
  "url": "https://github.com/databricks/cli.git"
}
```

