Skip to content

Add a new SSH key

POST
/users/{selected_user}/ssh-keys

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

Example:

$ curl -X POST -H "Content-Type: application/json" -d '{"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKqP3Cr632C2dNhhgKVcon4ldUSAeKiku2yP9O9/bDtY user@myhost"}' https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-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}.

expires_on
string

The date or date-time of when the key will expire, in ISO-8601 format. Example: YYYY-MM-DDTHH:mm:ss.sssZ

The new SSH key object. Note that the username property has been deprecated due to privacy changes.

Media type application/json
object
type
required
string
uuid

The SSH key’s immutable ID.

string
key

The SSH public key value in OpenSSH format.

string
comment

The comment parsed from the SSH key (if present)

string
label

The user-defined label for the SSH key

string
created_on
string format: date-time
last_used
string format: date-time
links
object
self
Link

A link to a resource related to this object.

object
href
string format: uri
name
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
expires_on
string format: date-time
fingerprint

The SSH key fingerprint in SHA-256 format.

string
Example generated
{
"type": "example",
"uuid": "example",
"key": "example",
"comment": "example",
"label": "example",
"created_on": "2026-04-15T12:00:00Z",
"last_used": "2026-04-15T12:00:00Z",
"links": {
"self": {
"href": "https://example.com",
"name": "example"
}
},
"owner": {
"type": "example",
"links": {
"avatar": {
"href": "https://example.com",
"name": "example"
}
},
"created_on": "2026-04-15T12:00:00Z",
"display_name": "example",
"uuid": "example"
},
"expires_on": "2026-04-15T12:00:00Z",
"fingerprint": "example"
}

The newly created SSH key.

Media type application/json
object
type
required
string
uuid

The SSH key’s immutable ID.

string
key

The SSH public key value in OpenSSH format.

string
comment

The comment parsed from the SSH key (if present)

string
label

The user-defined label for the SSH key

string
created_on
string format: date-time
last_used
string format: date-time
links
object
self
Link

A link to a resource related to this object.

object
href
string format: uri
name
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
expires_on
string format: date-time
fingerprint

The SSH key fingerprint in SHA-256 format.

string
Examples
Example response
{
"comment": "user@myhost",
"created_on": "2018-03-14T13:17:05.196003+00:00",
"expires_on": null,
"fingerprint": "w9tZSiFoZ8oXwS4ZSWrJopGxwvnPIewA6Mo4owAHPrI",
"key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKqP3Cr632C2dNhhgKVcon4ldUSAeKiku2yP9O9/bDtY",
"label": "",
"last_used": "2018-03-20T13:18:05.196003+00:00",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/users/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}/ssh-keys/b15b6026-9c02-4626-b4ad-b905f99f763a"
}
},
"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/{ed08f5e1-605b-4f4a-aee4-6c97628a673e}"
}
},
"type": "user",
"username": "markadams-atl",
"nickname": "markadams-atl",
"uuid": "{d7dd0e2d-3994-4a50-a9ee-d260b6cefdab}"
},
"type": "ssh_key",
"uuid": "{b15b6026-9c02-4626-b4ad-b905f99f763a}"
}

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": {}
}
}