# Connect Bitbucket

> Connect a Bitbucket Cloud account to AI CodeOps with OAuth so sessions can push branches and open pull requests, plus the limits of token-based connections.

Source: https://aicodeops.dev/docs/git/bitbucket

AI CodeOps works with repositories in Bitbucket Cloud workspaces. Connect your Bitbucket account once; sessions then write changes on a new branch and open a pull request for review.

## Before you start

- A Bitbucket Cloud account with write access to the repositories you want to use.
- Bitbucket Server and Data Center aren't supported.

## Connect with OAuth

This is the recommended way to connect Bitbucket.

1. In your workspace, open **Configure → Settings** and scroll to **Git Providers**.
2. On the **Bitbucket** card, choose **Connect**.
3. Bitbucket asks you to grant access. Approve it, and you return to Settings with the account under **Connected Accounts**.

Bitbucket shows the permissions on its consent screen. AI CodeOps uses them to read your account and repositories, push branches, and create and merge pull requests. OAuth tokens are refreshed automatically before they expire.

If you see "Bitbucket sign-in isn't set up on this server", the platform's OAuth consumer isn't available. Contact support.

## Token connections

The card also has a token field, **or access token (no OAuth app)**. AI CodeOps sends that token to Bitbucket as a Bearer token. Bitbucket app passwords and API tokens that need your username or email alongside them won't work in this field. If a token is refused with "Token rejected — check the URL and key.", connect with OAuth instead.

## What AI CodeOps does with the repository

- **Browse:** **Develop → Repositories** lists the repositories the account can see, with branches, files and pull requests.
- **Branches and pull requests:** when a change is approved and passes its [quality gates](https://aicodeops.dev/docs/quality-gates), AI CodeOps pushes a branch named `codeops/run-<id>` and opens a pull request into the project's default branch. Commits are authored as "AI CodeOps".
- **Merge:** a pull request the console opened can be merged from the console. The release gate runs again first.

AI CodeOps doesn't add webhooks to your repositories or comment on pull requests.

## Your token and your access

- A connection belongs to you, not the workspace. Workspace roles still decide what each member can do.
- Tokens are encrypted at rest (AES-256-GCM) and aren't written into any repository's Git configuration.
- To remove access, choose **Disconnect** next to the account. You can also revoke AI CodeOps's access in your Bitbucket settings.

## Next steps

- [Create a project](https://aicodeops.dev/docs/projects) from a Bitbucket repository.
- [Run your first session](https://aicodeops.dev/docs/sessions).
- [Troubleshooting](https://aicodeops.dev/docs/troubleshooting)
