Connections API
The Connections API allows you to manage code host connections.
Connections Status
Section titled “Connections Status”Check if connections management is in read-only mode.
GET /api/v1/connections/statusResponse
Section titled “Response”{ "readonly": true, "message": "Connections are managed via configuration file. Changes through the UI are disabled."}When not read-only:
{ "readonly": false}List Connections
Section titled “List Connections”Get all configured connections.
GET /api/v1/connectionsResponse
Section titled “Response”[ { "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 Connection
Section titled “Get Connection”Get a specific connection by ID.
GET /api/v1/connections/{id}Response
Section titled “Response”{ "id": 1, "name": "github-work", "type": "github", "url": "https://api.github.com", "exclude_archived": true, "created_at": "2024-01-01T00:00:00Z"}Create Connection
Section titled “Create Connection”Create a new code host connection.
POST /api/v1/connectionsRequest Body
Section titled “Request Body”{ "name": "github-work", "type": "github", "url": "https://api.github.com", "token": "ghp_xxxxxxxxxxxx", "exclude_archived": true}{ "name": "gitlab-internal", "type": "gitlab", "url": "https://gitlab.example.com", "token": "glpat-xxxxxxxxxxxx", "exclude_archived": true}{ "name": "gitea-self", "type": "gitea", "url": "https://gitea.example.com", "token": "xxxxxxxxxx", "exclude_archived": false}{ "name": "bitbucket-cloud", "type": "bitbucket", "url": "https://api.bitbucket.org/2.0", "token": "xxxxxxxxxx", "exclude_archived": true}Response (201 Created)
Section titled “Response (201 Created)”{ "id": 3, "name": "github-work", "type": "github", "url": "https://api.github.com", "exclude_archived": true, "created_at": "2024-01-15T12:00:00Z"}Update Connection
Section titled “Update Connection”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}Request Body
Section titled “Request Body”{ "name": "github-work-updated", "type": "github", "url": "https://api.github.com", "token": "", "exclude_archived": true}Response
Section titled “Response”{ "id": 1, "name": "github-work-updated", "type": "github", "url": "https://api.github.com", "exclude_archived": true, "created_at": "2024-01-01T00:00:00Z"}Delete Connection
Section titled “Delete Connection”Delete a connection. Associated repositories are also removed.
DELETE /api/v1/connections/{id}Response
Section titled “Response”Returns 204 No Content on success.
Test Connection
Section titled “Test Connection”Test if a connection’s credentials are valid.
POST /api/v1/connections/{id}/testResponse (success)
Section titled “Response (success)”{ "status": "ok", "message": "Connection validated successfully"}Response (failure)
Section titled “Response (failure)”{ "status": "error", "error": "Invalid token or insufficient permissions"}Sync Connection
Section titled “Sync Connection”Queue a job to fetch repositories from a connection. The actual fetching happens asynchronously.
POST /api/v1/connections/{id}/syncResponse
Section titled “Response”{ "status": "queued", "job_id": 789, "message": "Sync job queued - repositories will be fetched in the background"}Conflict Response (409)
Section titled “Conflict Response (409)”If a sync is already in progress:
{ "status": "already_syncing", "message": "Connection sync job already running"}List Connection Repositories
Section titled “List Connection Repositories”List all repositories that belong to a specific connection.
GET /api/v1/connections/{id}/reposResponse
Section titled “Response”[ { "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" }]Examples
Section titled “Examples”# Check if connections are read-onlycurl "http://localhost:8080/api/v1/connections/status"
# List connectionscurl "http://localhost:8080/api/v1/connections"
# Get a specific connectioncurl "http://localhost:8080/api/v1/connections/1"
# Create connectioncurl -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 connectioncurl -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 credentialscurl -X POST "http://localhost:8080/api/v1/connections/1/test"
# Trigger synccurl -X POST "http://localhost:8080/api/v1/connections/1/sync"
# List repos for a connectioncurl "http://localhost:8080/api/v1/connections/1/repos"
# Delete connectioncurl -X DELETE "http://localhost:8080/api/v1/connections/1"const API = 'http://localhost:8080/api/v1';
// Check if connections are read-onlyconst status = await fetch(`${API}/connections/status`).then(r => r.json());console.log('Read-only:', status.readonly);
// List connectionsconst connections = await fetch(`${API}/connections`).then(r => r.json());
// Get a specific connectionconst connection = await fetch(`${API}/connections/1`).then(r => r.json());
// Create connectionconst newConn = await fetch(`${API}/connections`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: 'github-work', type: 'github', url: 'https://api.github.com', token: 'ghp_xxxx', exclude_archived: true })}).then(r => r.json());
// Test connectionconst test = await fetch(`${API}/connections/1/test`, { method: 'POST'}).then(r => r.json());
// Trigger syncconst sync = await fetch(`${API}/connections/1/sync`, { method: 'POST'}).then(r => r.json());
// List repos for a connectionconst repos = await fetch(`${API}/connections/1/repos`).then(r => r.json());import requests
API = "http://localhost:8080/api/v1"
# Check if connections are read-onlystatus = requests.get(f"{API}/connections/status").json()print(f"Read-only: {status['readonly']}")
# List connectionsconnections = requests.get(f"{API}/connections").json()
# Get a specific connectionconnection = requests.get(f"{API}/connections/1").json()
# Create connectionnew_conn = requests.post( f"{API}/connections", json={ "name": "github-work", "type": "github", "url": "https://api.github.com", "token": "ghp_xxxx", "exclude_archived": True }).json()
# Test connectiontest = requests.post(f"{API}/connections/1/test").json()
# Trigger syncsync = requests.post(f"{API}/connections/1/sync").json()
# List repos for a connectionrepos = requests.get(f"{API}/connections/1/repos").json()Connection Types
Section titled “Connection Types”| Type | Description |
|---|---|
github | GitHub.com or GitHub Enterprise |
gitlab | GitLab.com or self-hosted GitLab |
gitea | Gitea instances |
bitbucket | Bitbucket Cloud or Bitbucket Server |
Repository Status Values
Section titled “Repository Status Values”| Status | Description |
|---|---|
pending | Waiting to be indexed |
indexed | Successfully indexed |
error | Indexing failed |
Next Steps
Section titled “Next Steps”- Jobs API - Monitor sync and indexing jobs
- Repositories API - Repository management