Хорошо, я заставил это работать, используя скрипт на Python 3.
#!/usr/bin/python3
import os
import requests, json
url = "https://api.bitbucket.org/2.0/users/userName/ssh-keys"
key = open(os.path.expanduser('~/.ssh/id_rsa.pub')).read()
print(key)
payload = {
"key": key,
"label": "testSSHKey"
}
header = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
response_decoded_json = requests.post(url, auth=requests.auth.HTTPBasicAuth('userName', 'password'), data=payload, headers=header)
response_json = response_decoded_json.json()
print(response_json)