Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

facing issue to GET PRIVATE REPOSITORY using api curl

Pankaj Kumar Malviya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 5, 2025

Hi Team,

Api_token I have created with read and write scope.

I am trying to access private repository using api curl but it is throwing error.

First try using Bearer Auth

--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_token}'

Error
{
"type": "error",
"error": {
"message": "Token is invalid, expired, or not supported for this endpoint."
}
}


Second Approach  (this is working for public repo but not working for private repo)

--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: {api_token}'


Error
{
"type": "error",
"error": {
"message": "You may not have access to this repository or it no longer exists in this workspace. If you think this repository exists and you have access, make sure you are authenticated."
}
}

Please suggest what is the missing parameter to GET PRIVATE REPOSITORY



1 answer

0 votes
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 9, 2025

G'day Pankaj!

 

To start using API tokens with Bitbucket Cloud - you'll need to create the API token and specify the scope - this is mentioned in our deprecation documentation:

  1. Click the gear cog icon, select Atlassian Account settings > Security tab > Create and manage API Tokens

  2. Click Create API token with scopes and select Bitbucket Cloud

  3. You’ll now need to define the scopes necessary for the API commands you’re intending to execute. A summary of these for common API operations is as follows - you can find more information on scopes in our API scopes documentation:
    Repository Operations

    • GET (Read):

      • Scope: read:repository:bitbucket

      • Allows viewing repository data, including source code and configurations.

    • POST/UPDATE (Write):

      • Scope: write:repository:bitbucket

      • Allows modifying repository data (e.g., updating source, branches, tags, forking).

    • DELETE:

      • Scope: delete:repository:bitbucket

      • Allows deletion of repositories.

    Pull Requests

    • GET (Read):

      • Scope: read:pullrequest:bitbucket

      • Allows viewing pull requests and commenting.

    • POST/UPDATE (Write):

      • Scope: write:pullrequest:bitbucket

      • Allows creating, updating, approving, declining, and merging pull requests.

    Issues

    • GET (Read):

      • Scope: read:issue:bitbucket

      • Allows viewing, listing, searching, and commenting on issues.

    • POST/UPDATE (Write):

      • Scope: write:issue:bitbucket

      • Allows creating, updating, transitioning, and deleting issues.

    Wikis

    • GET/POST/UPDATE/DELETE:

      • Scope: wiki:bitbucket

      • Provides both read and write access to wikis (view, create, edit, push, clone).

    Snippets

    • GET (Read):

      • Scope: read:snippet:bitbucket

    • POST/UPDATE (Write):

      • Scope: write:snippet:bitbucket

    • DELETE:

      • Scope: delete:snippet:bitbucket

    Pipelines

    • GET (Read):

      • Scope: read:pipeline:bitbucket

    • POST/UPDATE (Write):

      • Scope: write:pipeline:bitbucket

  4. Perform the API command by using the API token with either of the sample commands below.

    Example 1: The API token, along with your Atlassian account email, can be sent as login credentials. For example:

    curl --request POST \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/commits' \ --user '{atlassian_account_email}:{api_token}' \ --header 'Accept: application/json'

    Example 2: Alternatively the API token can be sent in a HTTP Authorization header after the Bitbucket email and API token have been base64 encoded. For example:

    my_credentials_after_base64_encoding=`echo -n '{atlassian_account_email}:{api_token}' | base64` curl --request POST \ --url 'https://api.bitbucket.org/2.0/repositories/{workspace}/{repository}/commits' \ --header "Authorization: Basic $my_credentials_after_base64_encoding" \ --header 'Accept: application/json'

Please perform the above and let me know how this goes. If you are still encountering issues, please let me know the scopes you’ve configured, and share the cURL command you’re executing (make sure to censor any credentials as this is a public forum).

Cheers!

- Ben (Bitbucket Cloud Support)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events