---
title: Linking code from Bitbucket Cloud
sidebarTitle: Bitbucket Cloud
---

import BitbucketToken from '/snippets/bitbucket-token.mdx';
import BitbucketAppPassword from '/snippets/bitbucket-app-password.mdx';
import BitbucketSchema from '/snippets/schemas/v3/bitbucket.schema.mdx'

## Examples

<AccordionGroup>
    <Accordion title="Sync individual repos">
        ```json
        {
            "type": "bitbucket",
            "deploymentType": "cloud",
            "repos": [
                "myWorkspace/myRepo"
            ]
        }
        ```
    </Accordion>
    <Accordion title="Sync all repos in a workspace">
        ```json
        {
            "type": "bitbucket",
            "deploymentType": "cloud",
            "workspaces": [
              "myWorkspace"
            ]
        }
        ```
    </Accordion>
    <Accordion title="Sync all repos in a project">
        ```json
        {
            "type": "bitbucket",
            "deploymentType": "cloud",
            "projects": [
                "myProject"
            ]
        }
        ```
    </Accordion>
    <Accordion title="Exclude repos from syncing">
        ```json
        {
            "type": "bitbucket",
            "deploymentType": "cloud",
            // Include all repos in my-workspace...
            "workspaces": [
                "myWorkspace"
            ],
            // ...except:
            "exclude": {
                // repos that are archived
                "archived": true,
                // repos that are forks
                "forks": true,
                // repos that match these glob patterns
                "repos": [
                    "myWorkspace/repo1",
                    "myWorkspace2/*"
                ]
            }
        }
        ```
    </Accordion>
</AccordionGroup>

## Authenticating with Bitbucket Cloud

In order to index private repositories, you'll need to provide authentication credentials. You can do this using an `App Password` or an `Access Token`

<Tabs>
    <Tab title="App Password">
      Navigate to the [app password creation page](https://bitbucket.org/account/settings/app-passwords/) and create an app password. Ensure that it has the proper permissions for the scope
      of info you want to fetch (i.e. workspace, project, and/or repo level) 
      ![Bitbucket App Password Permissions](/images/bitbucket_app_password_perms.png)

      Next, provide your username + app password pair to Sourcebot:

      <BitbucketAppPassword />
    </Tab>
    <Tab title="Access Token">
      Create an access token for the desired scope (repo, project, or workspace). Visit the official [Bitbucket Cloud docs](https://support.atlassian.com/bitbucket-cloud/docs/access-tokens/)
      for more info.

      Next, provide the access token to Sourcebot:

      <BitbucketToken />
    </Tab>
</Tabs>


## Schema reference

<Accordion title="Reference">
[schemas/v3/bitbucket.json](https://github.com/sourcebot-dev/sourcebot/blob/main/schemas/v3/bitbucket.json)

<BitbucketSchema />

</Accordion>