deploy-keys Resource

Overview

Manage ssh keys used for deploying product builds. All the calls for this resource require authentication as the account owner. The deploy-keys fields are the following:

Field Description
pk The key identifier (ID).
key Public key value.
label The user-visible label on the key.

You cannot update an existing deploy key.  Instead, you must DELETE the key and recreate a new one with a POST call.

GET a list of keys

Gets a list of the keys associated with an repository. You can specify the following parameters with this call:

Parameter
Required?
Description
accountname Yes The team or individual account.
repo_slug Yes The repo identifier (not to be confused with the repo's name).
GET https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/deploy-keys 
  Click here to expand the response...

GET the key's content

Gets the content of the specified key_id. This call requires authentication. You can specify the following parameters with this call:

Parameter
Required?
Description
accountname Yes The team or individual account.
repo_slug Yes The repo identifier (not to be confused with the repo's name).
pk Yes The key identifier assigned by Bitbucket. Use the GET call to obtain this value.
 GET https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/deploy-keys/{pk}
  Click here to expand...

POST a new key

Creates a key on the specified account. You must supply a valid key that is unique across the Bitbucket service. A public key contains characters need to be escaped before sending it as a POST data. So, use the proper escaping ( urlencode ), if you are testing to add a key via your terminal. This call requires authentication. You can specify the following parameters with this call:

Parameter
Required?
Description
accountname Yes The team or individual account.
repo_slug Yes The repo identifier (not to be confused with the repo's name).
label No A display name for the key.
key Yes The content of the key.
POST https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/deploy-keys --data "key=value"
  Click here to expand the response...

DELETE a key

Deletes the key specified by the key_id value. This call requires authentication. You can specify the following parameters with this call:

Parameter
Required?
Description
accountname Yes The team or individual account.
repo_slug Yes The repo identifier (not to be confused with the repo's name).
pk Yes The key identifier assigned by Bitbucket. Use the GET call to obtain this value.
DELETE https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/deploy-keys/{pk}

Returns HTTP 204 on success.

Was this helpful?

Thanks for your feedback!

3 Archived comments

  1. User avatar

    Yong Gu

    Is there any way to prevent the email notification after the key is added? When i use codeship, i can see that the key is added but i do not receive any email notification. I went through the document but could not find the way to do it. Please advise. Thanks.

    17 Nov 2014
    1. User avatar

      Dan Stevens [Atlassian]

      Hey Yong,

      I do not think there is a way to disable email notification's for when you add a deploy key. Mostly this is so you always know when an access change is made to your account.

      You can disable email notifications altogether if you want a more extreme solution. If you just want to stop email notifications another solution might be to use the HipChat integration and just select the notifications you want. Of course that means installing and running HipChat, so I suppose that was a mildly shameless promotion. (smile)

      Happy coding,

      Dan

      17 Nov 2014
  2. User avatar

    Igor Támara

    If you want to use curl to create a new repository, you can do that with something like:

    curl -v --request POST --user USERNAME:PASSWORD https://bitbucket.org/api/1.0/repositories/accountname/repo_slug/deploy-keys --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"key": "your key contents", "label": "identification"}'

     

    In case you struggle with this.

     

    12 Feb 2015
Powered by Confluence and Scroll Viewport