Code references

Create repository

POST
/api/v2/code-refs/repositories

Create a repository with the specified name.

Authorization

ApiKey read, write
Authorization<token>

In: header

Scope: read, write

Request Body

application/json

name*string

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?string

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

Value in

  • "bitbucket"
  • "custom"
  • "github"
  • "gitlab"
defaultBranch?string

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

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/v2/code-refs/repositories" \  -H "Content-Type: application/json" \  -d '{    "name": "LaunchDarkly-Docs"  }'
{  "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",  "enabled": true,  "version": 3,  "branches": [    {      "name": "main",      "head": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",      "updateSequenceId": 25,      "syncTime": "1636558831870",      "references": [        {          "path": "/main/index.js",          "hint": "javascript",          "hunks": [            {              "startingLineNumber": 45,              "lines": "var enableFeature = 'enable-feature';",              "projKey": "default",              "flagKey": "enable-feature",              "aliases": [                "enableFeature",                "EnableFeature"              ]            }          ]        }      ],      "_links": {        "property1": null,        "property2": null      }    }  ],  "_links": {    "property1": null,    "property2": null  },  "_access": {    "denied": [      {        "action": "string",        "reason": {          "resources": [            "proj/*:env/*;qa_*:/flag/*"          ],          "notResources": [            "string"          ],          "actions": [            "*"          ],          "notActions": [            "string"          ],          "effect": "allow",          "role_name": "string"        }      }    ],    "allowed": [      {        "action": "string",        "reason": {          "resources": [            "proj/*:env/*;qa_*:/flag/*"          ],          "notResources": [            "string"          ],          "actions": [            "*"          ],          "notActions": [            "string"          ],          "effect": "allow",          "role_name": "string"        }      }    ]  }}