Expecto CentumEXPECTO CENTUM
Download
Download
Manuscripts · Covenants · Bitbucket

Connect Bitbucket with an Atlassian API token

Bind Bitbucket to Expecto Centum so the Publish stage can push commits and open pull requests on your behalf — an Atlassian API token, scoped narrowly to the seven Bitbucket permissions the pipeline actually needs.

Published
✦ Before you begin

You'll need: an Atlassian account with access to the Bitbucket workspaces you want the pipeline to publish into, the email address registered on that account, and the Expecto Centum desktop app installed.

Bitbucket Cloud authenticates with an Atlassian API token. Tokens authenticate as HTTP Basic with your Atlassian email as the username and the token as the password; the desktop app combines the two on every request. The token inherits your Bitbucket permissions exactly, so whatever your user can do in the browser, the pipeline can do through the token.

Bitbucket uses Atlassian's API token with scopes wizard. The scopes are granular and don't imply each other — every one of the seven the pipeline needs has to be ticked individually. The resulting token is encrypted and stored on this device; nothing leaves the machine.

✦

Step I Open the Atlassian API tokens page

Sign in to your Atlassian account and open the API tokens page at id.atlassian.com/manage-profile/security/api-tokens. The page lists any existing tokens and exposes two creation buttons in the top right.

You can also reach it from your Atlassian avatar → Manage account → Security → Create and manage API tokens.

✦ Two buttons — pick the right one

Click Create API token with scopes. The plain Create API token button next to it produces a Jira-style token with no scopes attached — it authenticates as your user against the Bitbucket API but every request comes back 403 because no permissions were granted. The scoped wizard is mandatory for Bitbucket.

✦✦✦✦Atlassian Account API Tokens page showing the Create API token, Create API token with scopes, and Revoke all API tokens buttons, with an Expecto Centum token listed below.
The Atlassian API Tokens page. Create API token with scopes is the one Bitbucket requires — the plain Create API token button to its left produces a token with no permissions.

Step II Create the token with scopes

The wizard walks you through four panes — Name and expiry, Select app, Select scopes, and Create token. Fill them in order.

On Name and expiry:

  1. Name — something you'll recognize later. We suggest Expecto Centum · {machine name} (e.g. Expecto Centum · mbp-m4) so you can tell which device owns the token when revoking.
  2. Expires on — pick a date up to 365 days out (Atlassian's hard ceiling). Tokens can't be renewed in place; when this date hits, you'll repeat Steps I–III and revoke the old one.
  3. Click Continue.
✦✦✦✦Atlassian API token wizard, Name and expiry pane, with Name set to Expecto Centum and Expires on set to May 12, 2027.
Name the token and pick an expiry (max 365 days).

On Select app:

  1. Select API token app — choose Bitbucket. Each token can only access one Atlassian product, so a Bitbucket token won't talk to Jira and vice versa.
  2. Click Continue.
✦✦✦✦Atlassian API token wizard, Select app pane, with Bitbucket selected as the API token app from a list that also includes Compass and Confluence.
Pick Bitbucket. The token can only access one product; Compass, Confluence, and Jira are separate token families.

On Select scopes, tick exactly these seven. Atlassian's scopes don't imply each other, so each one has to be selected individually — start with the admin scope and the four read scopes:

  • admin:repository:bitbucket — create a new repo when you pick Create new repo instead of an existing one; Bitbucket refuses to create a repo without it, even with the write scope granted.
  • read:pullrequest:bitbucket — find open PRs and read merge state for the Reaper stage.
  • read:repository:bitbucket — list and clone repos.
  • read:user:bitbucket — used by the initial reachability check (GET /2.0/user); without it the token verifies as 403 even when every other scope is fine.
  • read:workspace:bitbucket — find your workspaces, to list their repos and to choose where a new repo goes: the first workspace you administer, or the first you belong to when you administer none.
✦✦✦✦Atlassian API token wizard, Select Bitbucket scopes pane, with read:pullrequest:bitbucket, read:repository:bitbucket, and read:user:bitbucket checked among the read scopes.
The read scopes ticked. read:workspace sits one page back in the alphabetical list — scroll up or change the sort.

Then the two write scopes:

  • write:pullrequest:bitbucket — open the PR for each ticket.
  • write:repository:bitbucket — push commits.

None of the other 38 scopes are required. Click Continue.

✦✦✦✦Atlassian API token wizard, Select Bitbucket scopes pane, with read:workspace:bitbucket, write:pullrequest:bitbucket, and write:repository:bitbucket checked among the write scopes.
Both write scopes ticked alongside read:workspace from the previous page.

On Create token, review the summary. The Admin section should list one scope, the Read section four and the Write section two — if anything is missing, hit Back rather than Create token, because the token can't be edited after creation. When everything matches, click Create token.

✦✦✦✦Atlassian API token wizard, Review your API token pane, showing the token name Windows VM, an expiry of Oct 11, 2027, the Bitbucket app, and the seven selected admin, read and write scopes.
The review pane — one admin scope, four read scopes, two write scopes, one app.

Step III Copy the token

Atlassian shows the token value once on the Create token pane. Click Copy and keep the window open until you've pasted it into Expecto Centum — the token starts with ATATT and runs about 192 characters.

✦✦✦✦Atlassian Copy API token pane, showing the new API token value, a Copy button, a warning to save the token before completing this step, and notes that Bitbucket APIs need the email while Git commands need the username.
The Copy API token pane. Atlassian's footnote distinguishes Bitbucket APIs (token + email) from Git commands (token + username) — Expecto Centum only needs the email pair, since it talks to the API for both PR creation and HTTPS push.
⚠ One-time reveal

Atlassian will not show this token again after you navigate away from this pane. If you lose it before pasting, revoke the token from the API tokens list and start over at Step II.

Step IV Paste into Expecto Centum

In the desktop app, open Config (the gear in the top-right of the dashboard) and select the Connections tab. Under Git provider connections, click Add Bitbucket. The dialog asks for:

  • Label — how this connection appears in the Connections list (e.g. Bitbucket (work)). Also used to derive the connection's stable id.
  • Host — https://bitbucket.org.
  • Atlassian email — the email registered on the Atlassian account that minted the token. Bitbucket's API uses Basic auth, so the email pairs with the token on every request.
  • API token — paste the value you copied in Step III. Input is password-masked; the value is never logged.

Click Save. Expecto Centum immediately probes Bitbucket with the credentials — a bad token, wrong email, or unreachable host rejects the add up front with a specific error (no half-registered connection lands on disk). On success, the token is encrypted and written to a machine-bound file alongside the app data, and the new row appears in the Connections list showing your Bitbucket username, the host, and a trash icon.

Step V Verify the connection

There's no separate verify step — the probe runs as part of Save, so a row appearing in the Connections list is the verification. The subtitle shows the authenticated Bitbucket username and host; if either looks wrong, trash the row and re-add with the correct email or host.

When you run a pipeline that publishes to a Bitbucket repo, the Publish stage resolves the connection bound to that repo and uses the stored token to push + open the PR. The repo → connection binding is set in Config → Context when you add the repo.

Step VI Rotating or revoking the token

Rotate before the expiry date, and immediately if a machine is lost or a teammate leaves. Atlassian doesn't renew tokens in place — rotating means minting a new one and discarding the old.

  • To rotate: mint a new token (Steps I–III) with a fresh name, trash the existing Bitbucket connection in the Connections tab (removes the encrypted token locally), then click Add Bitbucket and paste the new value. Finally, revoke the old token on the Atlassian API tokens page so it's invalidated server-side.
  • To revoke: open the Atlassian API tokens page, find the token by its name, and click Revoke. Then trash the connection in Expecto Centum so the stale entry is purged locally.

✦ Troubleshooting

“401 Unauthorized” when saving

Double-check that the Atlassian email matches the account that generated the token. Tokens are tied to a specific Atlassian user — a token created by alice@acme.com won't authenticate as alice@gmail.com, even if the two accounts are linked. Also confirm the token hasn't been revoked or expired on Atlassian.

“403 Forbidden” on the probe with all seven scopes ticked

Almost always means read:user:bitbucket was missed. The probe calls GET /2.0/user as a reachability check, which requires that scope specifically — without it the token comes back valid and 403, which looks like a permissions problem on a workspace but is actually a missing scope on the token itself. Mint a new token with read:user:bitbucket ticked and re-add.

“403 Forbidden” on a specific repo during publish

The token inherits your Bitbucket permissions exactly — if you can't push to the repo in a browser, the token can't either. Ask a workspace admin to grant at least Write on the relevant repository, or move the repo into a workspace where you have it.

Bitbucket evaluates workspace permissions before repo permissions, so a workspace-level Read can still block writes even when the token's write:repository:bitbucket scope is present. The scope authorizes the API call; your workspace role still has to authorize the underlying action.

Token rejected even though ‘Create API token’ succeeded

You clicked the wrong button on the API tokens page — the plain Create API token (Jira-style) mints a scopeless token that authenticates but can't see any Bitbucket resource. The Bitbucket flavor requires Create API token with scopes. Revoke the wrong one from the API tokens list and start again at Step I.

Corporate SSO / SAML orgs

API tokens still work for your individual user even if your Atlassian org enforces SAML. If an admin has disabled API token access org-wide, you'll need them to re-enable it for the account Expecto Centum should authenticate as.

✦