> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coderabbit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Bitbucket Cloud

> Learn how to integrate CodeRabbit with Bitbucket Cloud repositories for automated AI-powered code reviews.

export const BitbucketBadge = ({tip = "This feature is available on Bitbucket.", title = "Bitbucket", cta, href, disabled = false}) => {
  return <Tooltip tip={tip} cta={cta} href={href}>
        <Badge icon="bitbucket" disabled={disabled || undefined}>
            {title}
        </Badge>
    </Tooltip>;
};

<BitbucketBadge />

<Info>
  For an overview of how CodeRabbit integrates with Git platforms, see [Add CodeRabbit to your repository](/platforms).

  For a hands-on tutorial with CodeRabbit performing code reviews on a live repository, see [Quickstart](/getting-started/quickstart).
</Info>

CodeRabbit integrates with Bitbucket Cloud to improve your development workflow by:

* **Automated code reviews** for newly created pull requests
* **Intelligent comments and suggestions** displayed directly on pull requests
* **Real-time bot interaction** for immediate feedback and assistance
* **Seamless webhook integration** for continuous monitoring

This guide walks you through integrating CodeRabbit with your Bitbucket Cloud repositories.

<Info>
  To interact with CodeRabbit in pull request comments, use `@coderabbitai` — or the username of the service account you configure below, if it differs.
</Info>

## Configure API Token

To enable CodeRabbit to interact with your Bitbucket repositories, you need to configure an API token. This token grants the necessary permissions for interacting with the Bitbucket pull request and discussion APIs.

<Warning>
  **Service Account Required**

  You must create a dedicated Bitbucket account specifically for CodeRabbit to ensure proper permissions and security isolation.
</Warning>

<Steps>
  <Step title="Create a CodeRabbit service account">
    Create a new Bitbucket account specifically for CodeRabbit and treat it as a
    service account.
  </Step>

  <Step title="Configure account settings">
    * Name the account "CodeRabbit" for easy identification
    * Use a dedicated email address for this service account
    * If your Bitbucket workspace requires two-step verification, enable it on this account as well
  </Step>

  <Step title="Generate API token">
    Generate an API Token to enable the integration between CodeRabbit and your
    Bitbucket repositories.
  </Step>
</Steps>

<Info>
  We recommend creating a dedicated service account and associating it with the
  workspace where you want to install CodeRabbit. During the installation
  process, CodeRabbit will automatically configure the required webhook for
  seamless integration.
</Info>

<Info>
  If you wish to change the review user, you must provide the API token for the
  new user who will post reviews and comments. However, this requires manually
  removing the previous user from the projects and associated webhooks. Once
  this is done, you will need to reinstall the CodeRabbit app for each project.
</Info>

### Best practices for service account setup

<CardGroup cols={1}>
  <Card icon="user" title="Account Configuration">
    * **Use "CodeRabbit" as the username** for easy recognition
    * **Use a dedicated email address** for management
    * **Use the CodeRabbit logo** as the profile picture ([download here](https://www.coderabbit.ai/brand))
  </Card>

  <Card icon="shield" title="Access Control">
    * **Grant developer access** to target projects
    * **Ensure workspace membership** for the service account
    * **Enable two-factor authentication** if required by workspace
  </Card>
</CardGroup>

<Warning>
  **Important:** Code reviews will be attributed to the owner of the API token.
  Ensure the service account is properly configured and recognizable to your
  team.
</Warning>

### Generate an API token

Bitbucket provides an option to generate an API token for your CodeRabbit service account. Follow these steps:

<Steps>
  <Step title="Log in to your service account">
    Log in using the user designated for CodeRabbit reviews. This user serves as a service account for managing reviews and related activities.
  </Step>

  <Step title="Navigate to API tokens">
    Go to [API
    Tokens](https://id.atlassian.com/manage-profile/security/api-tokens) in your Atlassian account settings.
  </Step>

  <Step title="Configure token details">
    * Enter a recognizable name for this API token (e.g., "CodeRabbit Integration")
    * Set an expiration date based on your security policy
    * On the next step, select **Bitbucket**
  </Step>

  <Step title="Select required scopes">
    Ensure the following scopes are selected for CodeRabbit to function properly:

    | Category           | Scope                         | Description                                                                                                                                                                                                                                                                                        |
    | ------------------ | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
    | **Account & User** | `read:account`                | Access account information                                                                                                                                                                                                                                                                         |
    |                    | `read:user:bitbucket`         | Read user profile data                                                                                                                                                                                                                                                                             |
    | **Repository**     | `read:repository:bitbucket`   | Read repository content and metadata                                                                                                                                                                                                                                                               |
    |                    | `write:repository:bitbucket`  | Write access for code analysis                                                                                                                                                                                                                                                                     |
    | **Pull Requests**  | `read:pullrequest:bitbucket`  | Read pull request information                                                                                                                                                                                                                                                                      |
    |                    | `write:pullrequest:bitbucket` | Post reviews and comments                                                                                                                                                                                                                                                                          |
    | **Issues**         | `read:issue:bitbucket`        | Read issue information                                                                                                                                                                                                                                                                             |
    |                    | `write:issue:bitbucket`       | Create and update issues                                                                                                                                                                                                                                                                           |
    | **Workspace**      | `read:workspace:bitbucket`    | Access workspace information                                                                                                                                                                                                                                                                       |
    |                    | `admin:project:bitbucket`     | Manage all project webhooks <Tooltip tip="Required in addition to write:webhook:bitbucket to create webhooks on any repository across your workspace projects. Otherwise CodeRabbit will not have the ability to install webhooks on repositories it does not already have access to.">ⓘ</Tooltip> |
    | **Webhooks**       | `read:webhook:bitbucket`      | Read webhook configurations                                                                                                                                                                                                                                                                        |
    |                    | `write:webhook:bitbucket`     | Create and manage webhooks                                                                                                                                                                                                                                                                         |
    | **Pipelines**      | `read:pipeline:bitbucket`     | Read pipeline information                                                                                                                                                                                                                                                                          |
    |                    | `read:runner:bitbucket`       | Access pipeline runner data                                                                                                                                                                                                                                                                        |
  </Step>

  <Step title="Generate and save token">
    * Click **Create**
    * **Important:** Copy and securely store the API token immediately as it will only be displayed once
  </Step>
</Steps>

<Warning>
  **Security Note:** The API token will only be displayed once upon creation.
  Make sure to copy and store it securely before leaving the page.
</Warning>

### Configure API token in CodeRabbit

You can provide your API token to CodeRabbit in two ways:

<Tabs>
  <Tab title="During Installation">
    CodeRabbit will automatically prompt you to provide the API token during the repository installation process if none is configured.
  </Tab>

  <Tab title="Pre-configure Token">
    To provide the token beforehand:

    1. Navigate to **Organization Settings** in the CodeRabbit app
    2. Select the **Bitbucket User** tab in the sidebar
    3. Enter your API token
    4. The token will be validated and saved for future use

    <Tip>
      You can verify the correct service account is selected by comparing the user ID shown in the UI with your service account's user ID.
    </Tip>
  </Tab>
</Tabs>

## Install CodeRabbit in your repositories

Once your API token is configured, you can install CodeRabbit in your Bitbucket repositories.

<Steps>
  <Step title="Access repository settings">
    Navigate to the [Repositories
    page](https://app.coderabbit.ai/settings/repositories) in the CodeRabbit
    app.
  </Step>

  <Step title="Select repositories">
    * Check the boxes next to specific repositories where you want to install CodeRabbit
    * To install on all repositories at once, select the checkbox at the top
  </Step>

  <Step title="Install repositories">
    Click **Install Repositories** to complete the setup.
  </Step>
</Steps>

<img src="https://mintcdn.com/coderabbit/69LGK0BhaHIxrC15/images/platforms/img/integrations/gitlab-repo-install.png?fit=max&auto=format&n=69LGK0BhaHIxrC15&q=85&s=f1ce504cee948da2087bc0b996dcdb6e" alt="Bitbucket Repo Install Modal" width="1874" height="1468" data-path="images/platforms/img/integrations/gitlab-repo-install.png" />

<Info>
  **Webhook Configuration:** The webhook
  `https://coderabbit.ai/bitbucketHandler` will be automatically installed for
  the selected projects, enabling CodeRabbit to monitor and review your pull
  requests.
</Info>

<img src="https://mintcdn.com/coderabbit/69LGK0BhaHIxrC15/images/platforms/img/integrations/bitbucket-webhook.png?fit=max&auto=format&n=69LGK0BhaHIxrC15&q=85&s=d67b856fee17794a4cfe2bcd43c9e5d4" alt="Bitbucket Webhook Example" width="1986" height="607" data-path="images/platforms/img/integrations/bitbucket-webhook.png" />

## Configure network access

If your instance requires IP allowlisting, add these CodeRabbit IP addresses to your firewall:

<CodeGroup>
  ```text IPs to allow list theme={null}
  35.222.179.152/32, 34.170.211.100/32, 136.113.208.247/32
  ```
</CodeGroup>

## Troubleshooting

If you encounter issues during setup or operation, here are common solutions:

<AccordionGroup>
  <Accordion title="Webhook Issues">
    If CodeRabbit isn't accessing repositories or reviewing pull requests:

    1. **Check webhook status** in your Bitbucket repository settings
    2. **Manually delete the webhook** if it exists but isn't working
    3. **Refresh the repository page** in the CodeRabbit app
    4. **Reinstall the webhook** using the CodeRabbit interface
  </Accordion>

  <Accordion title="Installation Problems">
    If you cannot install the webhook:

    * **Verify permissions**: Ensure your Bitbucket service account has the necessary permissions
    * **Check API token**: Confirm the API token is properly configured with all required scopes
    * **Validate account access**: Ensure the service account has developer access to target repositories
  </Accordion>

  <Accordion title="Authentication Errors">
    If you're seeing authentication issues:

    * **Regenerate API token** with the correct scopes
    * **Update token in CodeRabbit** Organization Settings
    * **Verify service account** has workspace membership
  </Accordion>
</AccordionGroup>

<Info>
  For additional support, visit the [support page](/support).
</Info>
