# Bitbucket API tokens: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/bitbucket
Last checked: 2026-10-25

Bitbucket Cloud API tokens are created from your Atlassian account (Security → Create and manage API tokens → Create API token with scopes), with an expiry date and Bitbucket scopes you choose. They are the long-term replacement for app passwords. The token is shown only once and cannot be viewed or edited later.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| API token (scoped, Bitbucket) | — | Yes | Scopes selected at creation; can be limited to a workspace | Set at creation; the maximum is not stated in the help page |

## How to create a Bitbucket key

1. Select your profile in the top navigation bar, open the Atlassian account page and choose the **Security** tab.
2. Select **Create and manage API tokens**, then **Create API token with scopes**.
3. Name the token, set an expiry date and select **Next**.
4. Select **Bitbucket** as the app, then choose the scopes the token needs (required for API access or Git commands).
5. Review and select **Create token**, then copy it; it is shown once.

## Limiting what the key can do

Scopes are chosen when the token is created and a token can be limited to a particular workspace. Pick only what the integration needs; scopes cannot be edited afterwards, so replace the token to change them.

## How to rotate a Bitbucket key

1. Create a new API token with the same scopes.
2. Update the systems that use the old token.
3. Revoke the old token.

## How to revoke a Bitbucket key

1. Open the Atlassian account **Security** tab and choose **Create and manage API tokens**.
2. Revoke the token that is no longer needed or has been compromised.

## If the key leaked

1. Revoke the token from the Atlassian API tokens page.
2. Create a replacement with narrower scopes and a shorter expiry.
3. Review recent repository and pipeline activity in the affected workspace.

## Gotchas

- API tokens cannot be viewed or edited after creation; you replace them instead.
- Organization admins cannot restrict API token creation for managed users on Bitbucket.
- Bitbucket tokens come from the Atlassian account, not from Bitbucket repository settings, so they appear alongside Jira and Confluence tokens.

## Using this key with AI agents (BotPassword)

- `list_credentials`: Lists the credentials this agent is granted and what it may do with each. Never values.
- `request_access`: Asks you for a grant, which you approve with your master password or decline in BotPassword on your desktop, never in the chat. The agent gets a receipt, never a value. Approval on your phone is planned.
- `run_with`: Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
- `http_request`: Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
- `rotate`: Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.
- `capture_secret`: Planned, not built yet: will read a newly created key straight from the page or command output into the vault.
- `store_secret`: Saves a value the agent already holds as a new vault item.

## FAQ

### Where do I create a Bitbucket API token?

In your Atlassian account under **Security** → **Create and manage API tokens** → **Create API token with scopes**, selecting Bitbucket as the app.

### Do Bitbucket API tokens replace app passwords?

Atlassian describes API tokens as the long-term replacement for app passwords.

### Can I see my Bitbucket API token again after creating it?

No. It is shown once; create a new token if you lose it.

### Can an AI agent use my Bitbucket key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a `.env` file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with `list_credentials`, `run_with`, `http_request`, so the agent gets the result and never the value.

## Sources

- https://support.atlassian.com/bitbucket-cloud/docs/api-tokens/
- https://support.atlassian.com/bitbucket-cloud/docs/create-an-api-token/
