curl --request PATCH \
--url https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
[
{
"op": "replace",
"path": "/defaultBranch",
"value": "main"
}
]
'import requests
url = "https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}"
payload = [
{
"op": "replace",
"path": "/defaultBranch",
"value": "main"
}
]
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([{op: 'replace', path: '/defaultBranch', value: 'main'}])
};
fetch('https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
[
'op' => 'replace',
'path' => '/defaultBranch',
'value' => 'main'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}"
payload := strings.NewReader("[\n {\n \"op\": \"replace\",\n \"path\": \"/defaultBranch\",\n \"value\": \"main\"\n }\n]")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"op\": \"replace\",\n \"path\": \"/defaultBranch\",\n \"value\": \"main\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"op\": \"replace\",\n \"path\": \"/defaultBranch\",\n \"value\": \"main\"\n }\n]"
response = http.request(request)
puts response.read_body{
"name": "LaunchDarkly-Docs",
"type": "github",
"defaultBranch": "main",
"enabled": true,
"version": 3,
"_links": {},
"sourceLink": "https://github.com/launchdarkly/LaunchDarkly-Docs",
"commitUrlTemplate": "https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}",
"hunkUrlTemplate": "https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}",
"branches": [
{
"name": "main",
"head": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
"syncTime": "1636558831870",
"_links": {},
"updateSequenceId": 25,
"references": [
{
"path": "/main/index.js",
"hunks": [
{
"startingLineNumber": 45,
"lines": "var enableFeature = 'enable-feature';",
"projKey": "default",
"flagKey": "enable-feature",
"aliases": [
"enableFeature",
"EnableFeature"
]
}
],
"hint": "javascript"
}
]
}
],
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
}
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Update repository
Update a repository’s settings. Updating repository settings uses a JSON patch or JSON merge patch representation of the desired changes. To learn more, read Updates.
curl --request PATCH \
--url https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
[
{
"op": "replace",
"path": "/defaultBranch",
"value": "main"
}
]
'import requests
url = "https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}"
payload = [
{
"op": "replace",
"path": "/defaultBranch",
"value": "main"
}
]
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify([{op: 'replace', path: '/defaultBranch', value: 'main'}])
};
fetch('https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
[
'op' => 'replace',
'path' => '/defaultBranch',
'value' => 'main'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}"
payload := strings.NewReader("[\n {\n \"op\": \"replace\",\n \"path\": \"/defaultBranch\",\n \"value\": \"main\"\n }\n]")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("[\n {\n \"op\": \"replace\",\n \"path\": \"/defaultBranch\",\n \"value\": \"main\"\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/code-refs/repositories/{repo}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"op\": \"replace\",\n \"path\": \"/defaultBranch\",\n \"value\": \"main\"\n }\n]"
response = http.request(request)
puts response.read_body{
"name": "LaunchDarkly-Docs",
"type": "github",
"defaultBranch": "main",
"enabled": true,
"version": 3,
"_links": {},
"sourceLink": "https://github.com/launchdarkly/LaunchDarkly-Docs",
"commitUrlTemplate": "https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}",
"hunkUrlTemplate": "https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}",
"branches": [
{
"name": "main",
"head": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
"syncTime": "1636558831870",
"_links": {},
"updateSequenceId": 25,
"references": [
{
"path": "/main/index.js",
"hunks": [
{
"startingLineNumber": 45,
"lines": "var enableFeature = 'enable-feature';",
"projKey": "default",
"flagKey": "enable-feature",
"aliases": [
"enableFeature",
"EnableFeature"
]
}
],
"hint": "javascript"
}
]
}
],
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
}
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Path Parameters
The repository name
Body
Response
Repository response
The repository name
"LaunchDarkly-Docs"
The type of repository
bitbucket, custom, github, gitlab "github"
The repository's default branch
"main"
Whether or not a repository is enabled for code reference scanning
true
The version of the repository's saved information
3
Show child attributes
Show child attributes
A URL to access the repository
"https://github.com/launchdarkly/LaunchDarkly-Docs"
A template for constructing a valid URL to view the commit
"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}"
A template for constructing a valid URL to view the hunk
"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}"
An array of the repository's branches that have been scanned for code references
Show child attributes
Show child attributes
Show child attributes
Show child attributes