• Addon
  • Branch restrictions
  • Branching model
  • Commit statuses
  • Commits
  • Deployments
  • Downloads
  • GPG
  • Issue tracker
  • Pipelines
  • Projects
  • Pullrequests
  • Refs
  • Reports
  • Repositories
  • SSH
  • Snippets
  • Source
  • Users
  • Webhooks
  • Workspaces
  • Other operations
Cloud
Bitbucket Cloud / Reference / REST APIs

GPG

Postman Collection
OpenAPI
GET

List GPG keys

Returns a paginated list of the user's GPG public keys. The key and subkeys fields can also be requested from the endpoint. See Partial Responses for more details.

Scopes
account
read:gpg-key:bitbucket

Request

Path parameters

selected_user

string

Required

Responses

A list of the GPG keys associated with the account.

application/json

Paginated GPG User Keys

A paginated list of GPG keys.

GET/users/{selected_user}/gpg-keys
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/users/{selected_user}/gpg-keys' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 { "page": 1, "pagelen": 10, "size": 1, "values": [ { "added_on": "2024-09-24T12:09:33.154081+00:00", "created_on": "2018-03-20T13:09:04.207005+00:00", "expires_on": null, "fingerprint": "h4m26ppxrol7blr7spbc7lhyymokdbnkxd06kzrt", "key_id": "ymokdbnkxd06kzrt", "last_used": "2024-09-25T15:18:05.196003+00:00", "links": { "self": { "href": "https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}/gpg-keys/H4M26PPXROL7BLR7SPBC7LHYYMOKDBNKXD06KZRT" } }, "name": "Alice's OpenPGP key", "owner": { "display_name": "Mark Adams", "links": { "avatar": { "href": "https://bitbucket.org/account/markadams-atl/avatar/32/" }, "html": { "href": "https://bitbucket.org/markadams-atl/" }, "self": { "href": "https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}" } }, "type": "user", "username": "markadams-atl", "nickname": "markadams-atl", "uuid": "{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}" }, "parent_fingerprint": null, "type": "gpg_key" } ] }
POST

Add a new GPG key

Adds a new GPG public key to the specified user account and returns the resulting key.

Example:

1 2 3 $ curl -X POST -H "Content-Type: application/json" -d '{"key": "<insert GPG Key>"}' https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}/gpg-keys
Scopes
account:write
read:gpg-key:bitbucket, write:gpg-key:bitbucket

Request

Path parameters

selected_user

string

Required

Request bodyapplication/json

The new GPG key object.

allOf [object, GPG Account Key]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

GPG Account Key

Represents a GPG public key for a user.

Responses

The newly created GPG key.

application/json

allOf [object, GPG Account Key]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

GPG Account Key

Represents a GPG public key for a user.

POST/users/{selected_user}/gpg-keys
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 curl --request POST \ --url 'https://api.bitbucket.org/2.0/users/{selected_user}/gpg-keys' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json' \ --header 'Content-Type: application/json' \ --data '{ "type": "<string>", "owner": { "type": "<string>" }, "key": "<string>", "key_id": "<string>", "fingerprint": "<string>", "parent_fingerprint": "<string>", "comment": "<string>", "name": "<string>", "expires_on": "<string>", "created_on": "<string>", "added_on": "<string>", "last_used": "<string>", "subkeys": [ { "type": "<string>" } ], "links": { "self": { "href": "<string>", "name": "<string>" } } }'
201Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 { "added_on": "2024-09-24T12:09:33.154081+00:00", "created_on": "2018-03-20T13:09:04.207005+00:00", "expires_on": null, "fingerprint": "h4m26ppxrol7blr7spbc7lhyymokdbnkxd06kzrt", "key_id": "ymokdbnkxd06kzrt", "last_used": "2024-09-25T15:18:05.196003+00:00", "links": { "self": { "href": "https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}/gpg-keys/H4M26PPXROL7BLR7SPBC7LHYYMOKDBNKXD06KZRT" } }, "name": "Alice's OpenPGP key", "owner": { "display_name": "Mark Adams", "links": { "avatar": { "href": "https://bitbucket.org/account/markadams-atl/avatar/32/" }, "html": { "href": "https://bitbucket.org/markadams-atl/" }, "self": { "href": "https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}" } }, "type": "user", "username": "markadams-atl", "nickname": "markadams-atl", "uuid": "{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}" }, "parent_fingerprint": null, "type": "gpg_key" }
GET

Get a GPG key

Returns a specific GPG public key belonging to a user. The key and subkeys fields can also be requested from the endpoint. See Partial Responses for more details.

Scopes
account
read:gpg-key:bitbucket

Request

Path parameters

fingerprint

string

Required
selected_user

string

Required

Responses

The specific GPG key matching the user and fingerprint.

application/json

allOf [object, GPG Account Key]

object

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

GPG Account Key

Represents a GPG public key for a user.

GET/users/{selected_user}/gpg-keys/{fingerprint}
1 2 3 4 curl --request GET \ --url 'https://api.bitbucket.org/2.0/users/{selected_user}/gpg-keys/{fingerprint}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
200Response
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 { "added_on": "2024-09-24T12:09:33.154081+00:00", "created_on": "2018-03-20T13:09:04.207005+00:00", "expires_on": null, "fingerprint": "h4m26ppxrol7blr7spbc7lhyymokdbnkxd06kzrt", "key_id": "ymokdbnkxd06kzrt", "last_used": "2024-09-25T15:18:05.196003+00:00", "links": { "self": { "href": "https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}/gpg-keys/H4M26PPXROL7BLR7SPBC7LHYYMOKDBNKXD06KZRT" } }, "name": "Alice's OpenPGP key", "owner": { "display_name": "Mark Adams", "links": { "avatar": { "href": "https://bitbucket.org/account/markadams-atl/avatar/32/" }, "html": { "href": "https://bitbucket.org/markadams-atl/" }, "self": { "href": "https://api.bitbucket.org/2.0/users/{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}" } }, "type": "user", "username": "markadams-atl", "nickname": "markadams-atl", "uuid": "{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}" }, "parent_fingerprint": null, "type": "gpg_key" }
DEL

Delete a GPG key

Deletes a specific GPG public key from a user's account.

Scopes
account:write
delete:gpg-key:bitbucket

Request

Path parameters

fingerprint

string

Required
selected_user

string

Required

Responses

The key has been deleted

DEL/users/{selected_user}/gpg-keys/{fingerprint}
1 2 3 curl --request DELETE \ --url 'https://api.bitbucket.org/2.0/users/{selected_user}/gpg-keys/{fingerprint}' \ --header 'Authorization: Bearer <access_token>'

Rate this page: