Skip to content

Connections API

The Connections API allows you to manage code host connections.

Check if connections management is in read-only mode.

GET /api/v1/connections/status
{
"readonly": true,
"message": "Connections are managed via configuration file. Changes through the UI are disabled."
}

When not read-only:

{
"readonly": false
}

Get all configured connections.

GET /api/v1/connections
[
{
"id": 1,
"name": "github-work",
"type": "github",
"url": "https://api.github.com",
"exclude_archived": true,
"created_at": "2024-01-01T00:00:00Z"
},
{
"id": 2,
"name": "gitlab-internal",
"type": "gitlab",
"url": "https://gitlab.example.com",
"exclude_archived": false,
"created_at": "2024-01-05T00:00:00Z"
}
]

Get a specific connection by ID.

GET /api/v1/connections/{id}
{
"id": 1,
"name": "github-work",
"type": "github",
"url": "https://api.github.com",
"exclude_archived": true,
"created_at": "2024-01-01T00:00:00Z"
}

Create a new code host connection.

POST /api/v1/connections
{
"name": "github-work",
"type": "github",
"url": "https://api.github.com",
"token": "ghp_xxxxxxxxxxxx",
"exclude_archived": true
}
{
"id": 3,
"name": "github-work",
"type": "github",
"url": "https://api.github.com",
"exclude_archived": true,
"created_at": "2024-01-15T12:00:00Z"
}

Update an existing connection. Requires all fields (name, type, url). Token is optional - if empty, the existing token is preserved.

PUT /api/v1/connections/{id}
{
"name": "github-work-updated",
"type": "github",
"url": "https://api.github.com",
"token": "",
"exclude_archived": true
}
{
"id": 1,
"name": "github-work-updated",
"type": "github",
"url": "https://api.github.com",
"exclude_archived": true,
"created_at": "2024-01-01T00:00:00Z"
}

Delete a connection. Associated repositories are also removed.

DELETE /api/v1/connections/{id}

Returns 204 No Content on success.

Test if a connection’s credentials are valid.

POST /api/v1/connections/{id}/test
{
"status": "ok",
"message": "Connection validated successfully"
}
{
"status": "error",
"error": "Invalid token or insufficient permissions"
}

Queue a job to fetch repositories from a connection. The actual fetching happens asynchronously.

POST /api/v1/connections/{id}/sync
{
"status": "queued",
"job_id": 789,
"message": "Sync job queued - repositories will be fetched in the background"
}

If a sync is already in progress:

{
"status": "already_syncing",
"message": "Connection sync job already running"
}

List all repositories that belong to a specific connection.

GET /api/v1/connections/{id}/repos
[
{
"id": 1,
"name": "org/repo-one",
"clone_url": "https://github.com/org/repo-one.git",
"default_branch": "main",
"branches": ["main", "develop"],
"status": "indexed",
"last_indexed": "2024-01-15T10:00:00Z"
},
{
"id": 2,
"name": "org/repo-two",
"clone_url": "https://github.com/org/repo-two.git",
"default_branch": "main",
"branches": ["main"],
"status": "pending"
}
]
Terminal window
# Check if connections are read-only
curl "http://localhost:8080/api/v1/connections/status"
# List connections
curl "http://localhost:8080/api/v1/connections"
# Get a specific connection
curl "http://localhost:8080/api/v1/connections/1"
# Create connection
curl -X POST "http://localhost:8080/api/v1/connections" \
-H "Content-Type: application/json" \
-d '{
"name": "github-work",
"type": "github",
"url": "https://api.github.com",
"token": "ghp_xxxx",
"exclude_archived": true
}'
# Update connection
curl -X PUT "http://localhost:8080/api/v1/connections/1" \
-H "Content-Type: application/json" \
-d '{
"name": "github-work-updated",
"type": "github",
"url": "https://api.github.com",
"exclude_archived": true
}'
# Test connection credentials
curl -X POST "http://localhost:8080/api/v1/connections/1/test"
# Trigger sync
curl -X POST "http://localhost:8080/api/v1/connections/1/sync"
# List repos for a connection
curl "http://localhost:8080/api/v1/connections/1/repos"
# Delete connection
curl -X DELETE "http://localhost:8080/api/v1/connections/1"
TypeDescription
githubGitHub.com or GitHub Enterprise
gitlabGitLab.com or self-hosted GitLab
giteaGitea instances
bitbucketBitbucket Cloud or Bitbucket Server
StatusDescription
pendingWaiting to be indexed
indexedSuccessfully indexed
errorIndexing failed