curl --request POST \
--url https://app.launchdarkly.com/api/v2/code-refs/repositories \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "LaunchDarkly-Docs",
"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}",
"type": "github",
"defaultBranch": "main"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/code-refs/repositories"
payload = {
"name": "LaunchDarkly-Docs",
"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}",
"type": "github",
"defaultBranch": "main"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'LaunchDarkly-Docs',
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}',
type: 'github',
defaultBranch: 'main'
})
};
fetch('https://app.launchdarkly.com/api/v2/code-refs/repositories', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'LaunchDarkly-Docs',
'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}',
'type' => 'github',
'defaultBranch' => '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"
payload := strings.NewReader("{\n \"name\": \"LaunchDarkly-Docs\",\n \"sourceLink\": \"https://github.com/launchdarkly/LaunchDarkly-Docs\",\n \"commitUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}\",\n \"hunkUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}\",\n \"type\": \"github\",\n \"defaultBranch\": \"main\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://app.launchdarkly.com/api/v2/code-refs/repositories")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"LaunchDarkly-Docs\",\n \"sourceLink\": \"https://github.com/launchdarkly/LaunchDarkly-Docs\",\n \"commitUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}\",\n \"hunkUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}\",\n \"type\": \"github\",\n \"defaultBranch\": \"main\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/code-refs/repositories")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"LaunchDarkly-Docs\",\n \"sourceLink\": \"https://github.com/launchdarkly/LaunchDarkly-Docs\",\n \"commitUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}\",\n \"hunkUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}\",\n \"type\": \"github\",\n \"defaultBranch\": \"main\"\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": "optimistic_locking_error",
"message": "Conflict. Optimistic lock error. Try again later."
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Create repository
Create a repository with the specified name.
curl --request POST \
--url https://app.launchdarkly.com/api/v2/code-refs/repositories \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "LaunchDarkly-Docs",
"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}",
"type": "github",
"defaultBranch": "main"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/code-refs/repositories"
payload = {
"name": "LaunchDarkly-Docs",
"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}",
"type": "github",
"defaultBranch": "main"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'LaunchDarkly-Docs',
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}',
type: 'github',
defaultBranch: 'main'
})
};
fetch('https://app.launchdarkly.com/api/v2/code-refs/repositories', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'LaunchDarkly-Docs',
'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}',
'type' => 'github',
'defaultBranch' => '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"
payload := strings.NewReader("{\n \"name\": \"LaunchDarkly-Docs\",\n \"sourceLink\": \"https://github.com/launchdarkly/LaunchDarkly-Docs\",\n \"commitUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}\",\n \"hunkUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}\",\n \"type\": \"github\",\n \"defaultBranch\": \"main\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://app.launchdarkly.com/api/v2/code-refs/repositories")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"LaunchDarkly-Docs\",\n \"sourceLink\": \"https://github.com/launchdarkly/LaunchDarkly-Docs\",\n \"commitUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}\",\n \"hunkUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}\",\n \"type\": \"github\",\n \"defaultBranch\": \"main\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/code-refs/repositories")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"LaunchDarkly-Docs\",\n \"sourceLink\": \"https://github.com/launchdarkly/LaunchDarkly-Docs\",\n \"commitUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}\",\n \"hunkUrlTemplate\": \"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}\",\n \"type\": \"github\",\n \"defaultBranch\": \"main\"\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": "optimistic_locking_error",
"message": "Conflict. Optimistic lock error. Try again later."
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Body
The repository name
"LaunchDarkly-Docs"
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}"
The type of repository. If not specified, the default value is custom.
bitbucket, custom, github, gitlab "github"
The repository's default branch. If not specified, the default value is main.
"main"
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