Deploy keys are managed through their own API endpoint:
/repositories/{workspace}/{repo_slug}/deploy-keys
Just POST a JSON payload to that URL that contains the key and label, e.g.
{
"key": "ssh-ed25519 AAAAc3z...",
"label": "my key"
}
If you generate an App Password, then you can add a deploy key to any repo that you have admin access to as follows (separate shell vars for readability):
BB_WORKSPACE="myworkspace"
BB_USER="myusername"
BB_PASS="oKoungoe7morerandomcharsae6PeewooFee"
BB_REPO="myrepo"
BB_KEY="ssh-ed25519 AAAAC3zNaCClZDImorerandomcharsTy0AC0YGKAMtZ+/Zk5teMaBvyrj3gtL6sFDdQQ"
# via curl...
curl -u "$BB_USER:$BB_PASS" \
-H "Content-Type: application/json" \
-d '{"key":"'"$BB_KEY"'", "label":"mykey@myserver"}' \
https://api.bitbucket.org/2.0/repositories/$BB_WORKSPACE/$BB_REPO/deploy-keys
# via httpie...
http -a $BB_USER:$BB_PASS \
https://api.bitbucket.org/2.0/repositories/$BB_WORKSPACE/$BB_REPO/deploy-keys \
key="$BB_KEY" \
label="mykey@myserver"