---
title: "Update repository"
method: PATCH
path: "/api/v2/code-refs/repositories/{repo}"
tags: ["Code references"]
---

# Update repository

`PATCH /api/v2/code-refs/repositories/{repo}`

Update a repository's settings. Updating repository settings uses a [JSON patch](https://datatracker.ietf.org/doc/html/rfc6902) or [JSON merge patch](https://datatracker.ietf.org/doc/html/rfc7386) representation of the desired changes. To learn more, read [Updates](https://launchdarkly.com/docs/api#updates).

## Path parameters

- `repo` string, string, required — The repository name

## Request body

- PatchOperation[]
  - `op` string, required — The type of operation to perform
  - `path` string, required — A JSON Pointer string specifying the part of the document to operate on
  - `value` string — A JSON value used in "add", "replace", and "test" operations

## Response `200`

Repository response

- RepositoryRep
  - `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

- `400` — Invalid request
- `401` — Invalid access token
- `403` — Forbidden
- `404` — Invalid resource identifier
- `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)
