For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Sign inTry it free
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
DocsGuidesSDKsIntegrationsAPI docsTutorialsFlagship blog
  • REST API overview
    • Access Tokens
    • Account Members
    • Account Usage Beta
    • AI Configs
    • Announcements
    • Applications Beta
    • Approvals
    • Approvals Beta
    • Audit Log
    • Code References
      • POSTCreate extinction
      • POSTCreate repository
      • POSTDelete branches
      • DELDelete repository
      • GETGet branch
      • GETGet code references statistics for flags
      • GETGet links to code reference repositories for each project
      • GETGet repository
      • GETList branches
      • GETList extinctions
      • GETList repositories
      • PATCHUpdate repository
      • PUTUpsert branch
    • Contexts
    • Context Settings
    • Custom Roles
    • Data Export Destinations
    • Environments
    • Experiments
    • Feature Flags
    • Feature Flags Beta
    • Flag Import Configurations Beta
    • Flag Links Beta
    • Flag Triggers
    • Follow Flags
    • Holdouts Beta
    • Insights Charts Beta
    • Insights Deployments Beta
    • Insights Flag Events Beta
    • Insights Pull Requests Beta
    • Insights Repositories Beta
    • Insights Scores Beta
    • Integration Audit Log Subscriptions
    • Integration Delivery Configurations Beta
    • Integrations Beta
    • Layers
    • Metrics
    • Metrics Beta
    • OAuth2 Clients
    • Persistent Store Integrations Beta
    • Projects
    • Relay Proxy Configurations
    • Release Pipelines Beta
    • Releases Beta
    • Scheduled Changes
    • Segments
    • Tags
    • Teams
    • Teams Beta
    • Users
    • Users Beta
    • User Settings
    • Views Beta
    • Webhooks
    • Workflows
    • Workflow Templates
    • Other
Sign inTry it free
LogoLogo
REST API overviewCode References

Create repository

POST
/api/v2/code-refs/repositories
POST
/api/v2/code-refs/repositories
$curl -X POST https://app.launchdarkly.com/api/v2/code-refs/repositories \
> -H "Authorization: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "name": "LaunchDarkly-Docs"
>}'
1{
2 "name": "LaunchDarkly-Docs",
3 "type": "github",
4 "defaultBranch": "main",
5 "enabled": true,
6 "version": 3,
7 "_links": {},
8 "sourceLink": "https://github.com/launchdarkly/LaunchDarkly-Docs",
9 "commitUrlTemplate": "https://github.com/launchdarkly/LaunchDarkly-Docs/commit/${sha}",
10 "hunkUrlTemplate": "https://github.com/launchdarkly/LaunchDarkly-Docs/blob/${sha}/${filePath}#L${lineNumber}",
11 "branches": [
12 {
13 "name": "main",
14 "head": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
15 "syncTime": 1636558831870,
16 "_links": {},
17 "updateSequenceId": 25,
18 "references": [
19 {
20 "path": "/main/index.js",
21 "hunks": [
22 {
23 "startingLineNumber": 45,
24 "lines": "var enableFeature = 'enable-feature';",
25 "projKey": "default",
26 "flagKey": "enable-feature",
27 "aliases": [
28 "enableFeature",
29 "EnableFeature"
30 ]
31 }
32 ],
33 "hint": "javascript"
34 }
35 ]
36 }
37 ],
38 "_access": {
39 "denied": [
40 {
41 "action": "string",
42 "reason": {
43 "effect": "allow",
44 "resources": [
45 "proj/*:env/*;qa_*:/flag/*"
46 ],
47 "notResources": [
48 "string"
49 ],
50 "actions": [
51 "*"
52 ],
53 "notActions": [
54 "string"
55 ],
56 "role_name": "string"
57 }
58 }
59 ],
60 "allowed": [
61 {
62 "action": "string",
63 "reason": {
64 "effect": "allow",
65 "resources": [
66 "proj/*:env/*;qa_*:/flag/*"
67 ],
68 "notResources": [
69 "string"
70 ],
71 "actions": [
72 "*"
73 ],
74 "notActions": [
75 "string"
76 ],
77 "role_name": "string"
78 }
79 }
80 ]
81 }
82}
Create a repository with the specified name.
Was this page helpful?
Previous

Delete branches

Next
Built with

Authentication

Authorizationstring
API Key authentication via header

Request

This endpoint expects an object.
namestringRequired
The repository name
sourceLinkstringOptional
A URL to access the repository
commitUrlTemplatestringOptional
A template for constructing a valid URL to view the commit
hunkUrlTemplatestringOptional
A template for constructing a valid URL to view the hunk
typeenumOptional

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

Allowed values:
defaultBranchstringOptional

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

Response

Repository response
namestring
The repository name
typeenum
The type of repository
Allowed values:
defaultBranchstring
The repository's default branch
enabledboolean
Whether or not a repository is enabled for code reference scanning
versioninteger
The version of the repository's saved information
_linksmap from strings to any
sourceLinkstring
A URL to access the repository
commitUrlTemplatestring
A template for constructing a valid URL to view the commit
hunkUrlTemplatestring
A template for constructing a valid URL to view the hunk
brancheslist of objects
An array of the repository's branches that have been scanned for code references
_accessobject

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
409
Conflict Error
429
Too Many Requests Error