Skip to main content
POST
/
api
/
v2
/
code-refs
/
repositories
Create repository
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"
}
'
{
  "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>"
        }
      }
    ]
  }
}

Documentation Index

Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Body

application/json
name
string
required

The repository name

Example:

"LaunchDarkly-Docs"

A URL to access the repository

Example:

"https://github.com/launchdarkly/LaunchDarkly-Docs"

commitUrlTemplate
string

A template for constructing a valid URL to view the commit

Example:

"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}"

hunkUrlTemplate
string

A template for constructing a valid URL to view the hunk

Example:

"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}"

type
enum<string>

The type of repository. If not specified, the default value is custom.

Available options:
bitbucket,
custom,
github,
gitlab
Example:

"github"

defaultBranch
string

The repository's default branch. If not specified, the default value is main.

Example:

"main"

Response

Repository response

name
string
required

The repository name

Example:

"LaunchDarkly-Docs"

type
enum<string>
required

The type of repository

Available options:
bitbucket,
custom,
github,
gitlab
Example:

"github"

defaultBranch
string
required

The repository's default branch

Example:

"main"

enabled
boolean
required

Whether or not a repository is enabled for code reference scanning

Example:

true

version
integer
required

The version of the repository's saved information

Example:

3

A URL to access the repository

Example:

"https://github.com/launchdarkly/LaunchDarkly-Docs"

commitUrlTemplate
string

A template for constructing a valid URL to view the commit

Example:

"https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}"

hunkUrlTemplate
string

A template for constructing a valid URL to view the hunk

Example:

"https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}"

branches
object[]

An array of the repository's branches that have been scanned for code references

_access
object