Update credentials for DVCS connections via REST API

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Updating the credentials for DVCS connections in the UI triggers a DVCS 'sync' because it involves accessing the org/repo page.

An alternative to updating DVCS connection credentials while avoiding this is to use some unpublished internal REST API endpoints.

⚠️ Unpublished Internal APIs: Please note that this article talks about using Jira Internal REST APIs. These, along with any internal REST API endpoints, are only tested for Jira's internal functionality and are not meant for setting up automation or client-use. These endpoints can be deprecated/decommissioned completely at any point without any prior notice. This article is for informational purposes only and outside of Atlassian Support's Scope.

Solution

  • The following endpoint can be used to update the DVCS Connection credentials via REST API:

1 POST /rest/bitbucket/1.0/organization/<organization_id>/credential
  • First, get the Organization ID that you need to update via REST API with either one of these methods:

1 2 GET /rest/bitbucket/1.0/organization/page <base_url>/rest/bitbucket/1.0/organization/page
  • Run this SQL query in your database, replacing the <ID> below, with your Organization's one, from the previous step. Then take note of the ACCESS_TOKEN value you get from the SQL query.

1 SELECT * FROM "AO_E8B6CC_ORGANIZATION_MAPPING" where "ID" = '<ID>'
  • The following updates the credentials for DVCS connections. Replace <new_key> and <new_secret> accordingly and replace the <access_token> with the ACCESS_TOKEN value from the previous step.

1 2 3 4 5 { "key": "<new_key>", "secret": "<new_secret>", "token": "<access_token>" }
  • The REST API to update DVCS connection credentials can also be called with the curl command:

1 2 3 4 curl -X POST -H "Content-Type: application/json" \ -d '{"key": "<new_key>", "secret": "<new_secret>", "token": "<access_token>"}' \ --header "Authorization: <auth>" \ <base_url>/rest/bitbucket/1.0/organization/<organization_id>/credential
    • The parameters <new_key>, <new_secret>, <access_token>, <auth>, <base_url>, and <organization_id> will need to be updated to match your environment.

    • <auth> can either be a Jira system administrator's basic authentication or a personal access token (PAT).

Updated on April 2, 2025

Still need help?

The Atlassian Community is here for you.