Migrate from the List Repos API

Warning

The List Repos API (GET /api/2.0/repos) is deprecated. Use the Workspace API and the Get Repo API instead.

Use the Workspace API to find Git folders by path. Call GET /api/2.0/repos/{repo_id} when you need Git metadata such as the branch, remote URL, or commit ID.

Replacement endpoints

Previous usage Replacement
Look up a Git folder by path GET /api/2.0/workspace/get-status
List Git folders in a directory GET /api/2.0/workspace/list
Read Git metadata (url, provider, branch, head_commit_id) GET /api/2.0/repos/{repo_id} with object_id from the Workspace API
Check CAN_MANAGE permission GET /api/2.0/permissions/repos/{repo_id}

Identify Git folders in Workspace API responses

An object from workspace/get-status or workspace/list is a Git folder when either condition is true:

  • object_type is "REPO".
  • object_type is "DIRECTORY" and directory_info.is_git_folder is true (Git folders with Git CLI access).

Look up a Git folder by path

Call GET /api/2.0/workspace/get-status with the workspace path. Pass the returned object_id to GET /api/2.0/repos/{repo_id} if you need Git metadata.

REST API

  1. Get the object status and object_id:

    curl --request GET \
      "https://<workspace-instance>/api/2.0/workspace/get-status?path=/Workspace/Users/user@example.com/my-repo" \
      --header "Authorization: Bearer $DATABRICKS_TOKEN"
    

    Example response for a Git folder with Git CLI access:

    {
      "object_type": "DIRECTORY",
      "path": "/Workspace/Users/user@example.com/my-repo",
      "object_id": 12345,
      "resource_id": "12345",
      "directory_info": {
        "is_git_folder": true
      }
    }
    
  2. Optional. Get Git metadata with object_id:

    curl --request GET \
      "https://<workspace-instance>/api/2.0/repos/12345" \
      --header "Authorization: Bearer $DATABRICKS_TOKEN"
    

CLI

REPO_ID=$(databricks workspace get-status "/Workspace/Users/user@example.com/my-repo" --output json | jq -r '.object_id')
databricks repos get "$REPO_ID"

List Git folders in a directory

Call GET /api/2.0/workspace/list on a folder and filter for Git folders. To search subdirectories, recurse into directories where object_type is "DIRECTORY" and directory_info.is_git_folder is not true.

REST API

curl --request GET \
  "https://<workspace-instance>/api/2.0/workspace/list?path=/Workspace/Users/user@example.com" \
  --header "Authorization: Bearer $DATABRICKS_TOKEN"

Filter objects for entries where object_type is "REPO" or directory_info.is_git_folder is true. Empty directories omit objects. Pass each matching object_id to GET /api/2.0/repos/{repo_id} only when you need Git metadata.

CLI

Requires Databricks CLI version 1.12.0 or later.

databricks workspace list "/Workspace/Users/user@example.com" --output json \
  | jq '.[] | select(.object_type == "REPO" or .directory_info.is_git_folder == true) | {id: .object_id, path: .path}'

Permissions

GET /api/2.0/repos returns only Git folders where the caller has CAN_MANAGE. workspace/get-status, workspace/list, and GET /api/2.0/repos/{repo_id} do not filter for CAN_MANAGE.

To check whether the caller has CAN_MANAGE, call GET /api/2.0/permissions/repos/{repo_id}. If you use a scope-restricted token, include read access to the access-management scope, such as access-management:read. See Narrow API scopes with scope modifiers.

With the required token scope, the endpoint returns HTTP 200 when the caller has CAN_MANAGE. An HTTP 403 (PERMISSION_DENIED) response can indicate insufficient token scopes or missing CAN_MANAGE permission. Verify the token's scopes before treating a denial as evidence that the caller lacks CAN_MANAGE.

Additional resources