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.
Bitbucket key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| API token (scoped, Bitbucket) Cannot manage workspace actions or log in to bitbucket.org. Does not require two-step verification. | — | 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
- Select your profile in the top navigation bar, open the Atlassian account page and choose the Security tab.
- Select Create and manage API tokens, then Create API token with scopes.
- Name the token, set an expiry date and select Next.
- Select Bitbucket as the app, then choose the scopes the token needs (required for API access or Git commands).
- 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
- Create a new API token with the same scopes.
- Update the systems that use the old token.
- Revoke the old token.
Tokens cannot be viewed or edited after creation, so rotation is create-then-revoke.
How to revoke a Bitbucket key
- Open the Atlassian account Security tab and choose Create and manage API tokens.
- Revoke the token that is no longer needed or has been compromised.
If your Bitbucket key leaked
- Revoke the token from the Atlassian API tokens page.
- Create a replacement with narrower scopes and a shorter expiry.
- Review recent repository and pipeline activity in the affected workspace.
Things that catch people out
- 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.
Recent incidents that put Bitbucket keys at risk
If you were affected by one of these, rotate your Bitbucket keys using the rotation steps above.
- Amazon Q Developer VS Code extension 1.84.0 shipped injected code after a CodeBuild token leak 2025-07-23
Using your Bitbucket key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Bitbucket key, these intents fit:
| Intent | What BotPassword does |
|---|---|
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. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
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.