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

# Bitbucket

> Connect a Bitbucket workspace so the Sazabi agent can search your code during investigations.

## Supported capabilities

Sandbox CLICore integration

* **Sandbox CLI**: [Bitbucket](https://docs.sazabi.com/catalogs/sandbox-clis/bitbucket.md) — Give the Sazabi agent the Bitbucket CLI (bb) in its sandbox to manage repositories, pull requests, and pipelines.
* **Core integration**: [Bitbucket](https://docs.sazabi.com/catalogs/integrations/bitbucket.md#core-integration) — Connect a Bitbucket workspace so the Sazabi agent can search your code during investigations.

Each connection method has its own setup and permissions. Connecting one method does not enable the others.

## Core integration

## About

Connecting Bitbucket gives the Sazabi agent read access to the repositories in a Bitbucket workspace, so it can search source and correlate errors with code while investigating. Bitbucket is a **forge** integration.

The agent can:

* Search and read source files across the workspace's repositories.
* Cross-reference stack traces and errors with the code that produced them.

## Prerequisites

* A Bitbucket workspace and its **workspace slug**.
* A Bitbucket **workspace access token** with read access to the repositories.
* Organization admin access in Sazabi.

## Set up in the dashboard

**Step 1**

### Create a workspace access token in Bitbucket

In Bitbucket, create a workspace access token scoped to read the
repositories you want Sazabi to search. Copy the token — Bitbucket shows it
once.

**Step 2**

### Open the Bitbucket integration

In the dashboard, go to [**Settings > Integrations > Bitbucket**](https://app.sazabi.com/settings/integrations/bitbucket).

**Step 3**

### Enter the workspace and token

Provide the **Workspace slug** and paste the **Workspace access token**,
then connect. Sazabi validates the token against the Bitbucket API before
saving.

## Set up with the CLI

You can also connect Bitbucket with the [Sazabi CLI](https://docs.sazabi.com/reference/cli.md) (installed and authenticated — see [CLI reference](https://docs.sazabi.com/reference/cli/integrations.md)).

Bitbucket is an API-key provider with two credential fields: the `workspace` slug and an `apiToken` (the workspace access token). Read the token from an environment variable rather than pasting it inline:

```bash theme={"system"}
export BITBUCKET_WORKSPACE_TOKEN=...   # your Bitbucket workspace access token
sazabi integrations connect bitbucket \
  --credentials "{\"workspace\":\"your-workspace-slug\",\"apiToken\":\"$BITBUCKET_WORKSPACE_TOKEN\"}"
```

Sazabi validates the token against the Bitbucket API before saving, the same as the dashboard path. Run `sazabi integrations list` to confirm the connection, or `sazabi integrations providers --json` to see each provider's credential fields.

## Code search

Once Bitbucket is connected and its repositories are mapped to a project, the Sazabi agent searches and reads those repositories to trace an error to the exact file and line during an investigation — cross-referencing a stack trace with the source that produced it. See [Agent tools](https://docs.sazabi.com/guides/investigate/agent-tools.md#your-code).

## Automated code review

> [!WARNING]
>
> **Limited release**
>
> Automated code review is currently in limited release and is not yet enabled for every organization. [Contact support](https://docs.sazabi.com/guides/administer/support.md) to request access.

Sazabi can review pull requests on Bitbucket with inline comments and a verdict. Enable it with the per-project master switch under [**Settings > Code**](https://app.sazabi.com/settings/code-search), then turn on this integration's own review toggle; request a review on demand by commenting `@Sazabi review` on a pull request.

See [Set up automated code review](https://docs.sazabi.com/guides/build/automated-code-review.md) for the full behavior — re-review on new commits, the on-demand request, and agent-opened pull requests.

## Ask the agent from a pull request

Bitbucket is also an **agent surface** — a place you can start an agent thread and read its response without leaving Bitbucket. Mention **@Sazabi** in a pull request comment with any request, and the agent investigates using your connected repositories and project data, then replies in the same comment thread. Keep replying in that thread to continue the conversation. This is separate from automated code review, which runs on its own.

## Connected account

You can also connect your personal Bitbucket account under [**Settings > Connected accounts**](https://app.sazabi.com/settings/connected-accounts) so the agent acts as you at Bitbucket. When you have a personal connection Sazabi uses it first and falls back to this organization integration otherwise. See [Connected accounts](https://docs.sazabi.com/guides/administer/connected-accounts.md).

## Verify

Open [**Settings > Integrations > Bitbucket**](https://app.sazabi.com/settings/integrations/bitbucket) and confirm the connection reads **connected** for your workspace. Then ask the agent, in a thread for the project the workspace is mapped to, to find a file or symbol you know exists in one of the workspace's repositories — it should return the file. If nothing is found, confirm the token has read access to that repository.

## Troubleshooting

**Token rejected on connect** — Confirm the workspace slug matches the token's workspace and that the token has repository read scope. Sazabi validates the token when you connect, so a rejection means the credential or scope is wrong.

**Connection shows needs attention** — The workspace access token may have expired or been revoked in Bitbucket. Create a new token and reconnect.

## Further reading

> [card] [Set up automated code review](https://docs.sazabi.com/guides/build/automated-code-review.md)
>
> Have Sazabi review new pull requests on Bitbucket.

> [card] [Code search](https://docs.sazabi.com/guides/investigate/agent-tools.md)
>
> How the agent searches your connected code.

> [card] [Integrations](https://docs.sazabi.com/catalogs/integrations.md)
>
> Browse the full integration catalog.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.