Skip to content

Add a new GPG key

POST
/users/{selected_user}/gpg-keys

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

Example:

$ 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
selected_user
required
string

This can either be an Atlassian Account ID OR the UUID of the account, surrounded by curly-braces, for example: {account UUID}.

The new GPG key object.

Media type application/json
object
type
required
string
owner
object
type
required
string
links
Account Links

Links related to an Account.

object
avatar
Link

A link to a resource related to this object.

object
href
string format: uri
name
string
key
additional properties
any
created_on
string format: date-time
display_name
string
uuid
string
key

The GPG key value in X format.

string
key_id

The unique identifier for the GPG key

string
fingerprint

The GPG key fingerprint.

string
parent_fingerprint

The fingerprint of the parent key. This value is null unless the current key is a subkey.

string
name

The user-defined label for the GPG key

string
expires_on
string format: date-time
created_on
string format: date-time
added_on
string format: date-time
last_used
string format: date-time
subkeys
Array<object> recursive
links
object
self
Link

A link to a resource related to this object.

object
href
string format: uri
name
string
Example generated
{
"type": "example",
"owner": {
"type": "example",
"links": {
"avatar": {
"href": "https://example.com",
"name": "example"
}
},
"created_on": "2026-04-15T12:00:00Z",
"display_name": "example",
"uuid": "example"
},
"key": "example",
"key_id": "example",
"fingerprint": "example",
"parent_fingerprint": "example",
"name": "example",
"expires_on": "2026-04-15T12:00:00Z",
"created_on": "2026-04-15T12:00:00Z",
"added_on": "2026-04-15T12:00:00Z",
"last_used": "2026-04-15T12:00:00Z",
"subkeys": [],
"links": {
"self": {
"href": "https://example.com",
"name": "example"
}
}
}

The newly created GPG key.

Media type application/json
object
type
required
string
owner
object
type
required
string
links
Account Links

Links related to an Account.

object
avatar
Link

A link to a resource related to this object.

object
href
string format: uri
name
string
key
additional properties
any
created_on
string format: date-time
display_name
string
uuid
string
key

The GPG key value in X format.

string
key_id

The unique identifier for the GPG key

string
fingerprint

The GPG key fingerprint.

string
parent_fingerprint

The fingerprint of the parent key. This value is null unless the current key is a subkey.

string
name

The user-defined label for the GPG key

string
expires_on
string format: date-time
created_on
string format: date-time
added_on
string format: date-time
last_used
string format: date-time
subkeys
Array<object> recursive
links
object
self
Link

A link to a resource related to this object.

object
href
string format: uri
name
string
Examples
Example response
{
"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"
}

If the submitted key or related value is invalid

Media type application/json
Error

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.

object
type
required
string
error
object
message
required
string
detail
string
data

Optional structured data that is endpoint-specific.

object
key
additional properties
any
key
additional properties
any
Example generated
{
"type": "example",
"error": {
"message": "example",
"detail": "example",
"data": {}
}
}

If the current user does not have permission to add a key for the specified user

If the specified user does not exist

Media type application/json
Error

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.

object
type
required
string
error
object
message
required
string
detail
string
data

Optional structured data that is endpoint-specific.

object
key
additional properties
any
key
additional properties
any
Example generated
{
"type": "example",
"error": {
"message": "example",
"detail": "example",
"data": {}
}
}