Table of Contents

, ,

Bitbucket Cloud API steps

Get oauth token

 curl -X POST -u "email:password" \
  https://bitbucket.org/site/oauth2/access_token \
  -d grant_type=client_credentials
 
 curl -sX POST -u "AUTHOKEN"   https://bitbucket.org/site/oauth2/access_token   -d grant_type=client_credentials
 
    {"access_token": "YOUR_LONG_ACCESS_TOKEN", "scopes": "pullrequest:write project:write account:write issue:write pipeline:variable snippet:write team:write webhook reposi...

Include above token in request on different endpoints

curl -s --header "Authorization: Bearer YOUR_LONG_ACCESS_TOKEN"   https://api.bitbucket.org/2.0/repositories | jq .

List repos

curl -s --header "Authorization: Bearer YOUR_LONG_ACCESS_TOKEN"   https://api.bitbucket.org/2.0/repositories/YOUR_USERNAME | jq .

Create new project (Mars example)

body=$(cat << EOF
{
    "name": "Mars Project",
    "key": "MARS",
    "description": "Software for colonizing mars.",
    "is_private": false
}
EOF
)
curl -s --header "Authorization: Bearer YOUR_LONG_ACCESS_TOKEN" --header "Content-Type: application/json"  -X POST -d "$body" https://api.bitbucket.org/2.0/teams/YOUR_TEAM/projects/ | jq .

Tested on

See also

Atlassian Bamboo API

References

https://developer.atlassian.com/bitbucket/api/2/reference/