---
title: "List repositories"
method: GET
path: "/api/v2/code-refs/repositories"
tags: ["Code references"]
---

# List repositories

`GET /api/v2/code-refs/repositories`

Get a list of connected repositories. Optionally, you can include branch metadata with the `withBranches` query parameter. Embed references for the default branch with `ReferencesForDefaultBranch`. You can also filter the list of code references by project key and flag key.

## Query parameters

- `withBranches` string, string — If set to any value, the endpoint returns repositories with associated branch data
- `withReferencesForDefaultBranch` string, string — If set to any value, the endpoint returns repositories with associated branch data, as well as code references for the default git branch
- `projKey` string, string — A LaunchDarkly project key. If provided, this filters code reference results to the specified project.
- `flagKey` string, string — If set to any value, the endpoint returns repositories with associated branch data, as well as code references for the default git branch

## Response `200`

Repository collection response

- RepositoryCollectionRep
  - `_links` object, required
  - `items` RepositoryRep[], required — An array of repositories
    - `name` string, required — The repository name
    - `sourceLink` string — A URL to access the repository
    - `commitUrlTemplate` string — A template for constructing a valid URL to view the commit
    - `hunkUrlTemplate` string — A template for constructing a valid URL to view the hunk
    - `type` 'bitbucket' | 'custom' | 'github' | 'gitlab', required — The type of repository
    - `defaultBranch` string, required — The repository's default branch
    - `enabled` boolean, required — Whether or not a repository is enabled for code reference scanning
    - `version` integer, required — The version of the repository's saved information
    - `branches` BranchRep[] — An array of the repository's branches that have been scanned for code references
      - `name` string, required — The branch name
      - `head` string, required — An ID representing the branch HEAD. For example, a commit SHA.
      - `updateSequenceId` integer — An optional ID used to prevent older data from overwriting newer data
      - `syncTime` integer, required
      - `references` ReferenceRep[] — An array of flag references found on the branch
        - `path` string, required — File path of the reference
        - `hint` string — Programming language used in the file
        - `hunks` HunkRep[], required
          - `startingLineNumber` integer, required — Line number of beginning of code reference hunk
          - `lines` string — Contextual lines of code that include the referenced feature flag
          - `projKey` string — The project key
          - `flagKey` string — The feature flag key
          - `aliases` string[] — An array of flag key aliases
      - `_links` object, required — The location and content type of related resources
    - `_links` object, required
    - `_access` Access
      - `denied` AccessDenied[], required
        - `action` string, required
        - `reason` AccessDeniedReason, required
          - `resources` string[] — Resource specifier strings
          - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
          - `actions` ActionSpecifier[] — Actions to perform on a resource
          - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
          - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
          - `role_name` string
      - `allowed` AccessAllowedRep[], required
        - `action` string, required
        - `reason` AccessAllowedReason, required
          - `resources` string[] — Resource specifier strings
          - `notResources` string[] — Targeted resources are the resources NOT in this list. The <code>resources</code> and <code>notActions</code> fields must be empty to use this field.
          - `actions` ActionSpecifier[] — Actions to perform on a resource
          - `notActions` ActionSpecifier[] — Targeted actions are the actions NOT in this list. The <code>actions</code> and <code>notResources</code> fields must be empty to use this field.
          - `effect` 'allow' | 'deny', required — Whether this statement should allow or deny actions on the resources.
          - `role_name` string

## Other responses

- `401` — Invalid access token
- `403` — Forbidden
- `429` — Rate limited

---

[API](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api.md) · [All operations](https://skmtc.dev/launchdarkly/apis/launchdarkly-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/launchdarkly/launchdarkly-rest-api/revisions/69c5c9aafe78/schema)
