Overview
When migrating your source control provider (for example, from Bitbucket to GitHub), you may notice that LaunchDarkly code references continue to link to your previous provider. This happens because code references are tied to the repository metadata used at the time they were scanned. Even after switching integrations and scanning from the new provider, older references are not automatically updated.
This article explains how to remove legacy code references that point to a previous source control provider using the Code References API, so that all references align with your current setup
Solution
You can remove legacy code references in two ways:
Option 1: Manually delete references via the Code references tab
-
Navigate to a flag in LaunchDarkly.
-
Click the Code references tab.
-
Manually delete outdated entries that point to your previous source control provider.
Option 2: Programmatically delete references using the Code References API
LaunchDarkly does not currently support automatic re-mapping of historical references to new repositories. However, you can fully automate the cleanup using the API.
Step 1: Identify legacy repositories
Use the following endpoint to list all known repositories:
curl -X GET \
'https://app.launchdarkly.com/api/v2/code-refs/repositories' \
-H 'Authorization: api-<your-access-token>' \
-H 'Content-Type: application/json'
This will return a list of repositories, including their repositoryKey
and repositoryType
. You can use the repositoryType
field to identify repositories associated with your old source control provider (e.g., bitbucket
).
Step 2: Delete outdated repositories and their references
Once you've identified the repositories linked to your previous provider, you can delete them using the following endpoint:
curl -X DELETE \
'https://app.launchdarkly.com/api/v2/code-refs/repositories/{repositoryKey}' \
-H 'Authorization: api-<your-access-token>' \
-H 'Content-Type: application/json'
Deleting a repository will remove all code references associated with it across all flags and environments.
Resources