Connect Repository
Repositories
Connect Repository
Connect a GitHub repository to enable AI-powered PR reviews
POST
Connect Repository
Overview
Connects a repository to Nectr AI by installing a webhook and initiating background tasks to scan the repository structure and build a code knowledge graph. This is a one-click operation that uses the user’s existing OAuth token (withrepo scope) - no GitHub redirect required.
Authentication
Requires a valid JWT token in theAuthorization header.
Path Parameters
string
required
Repository owner (user or organization)
string
required
Repository name
Request
Response
string
Always returns
"connected" on successinteger
Database ID of the newly created installation record
string
Full repository name in
owner/repo formatExample Response
What Happens During Connection
1. Webhook Installation
A GitHub webhook is created on the repository with:- Events:
pull_request,issues - Payload URL:
{BACKEND_URL}/api/v1/webhooks/github - Secret: Randomly generated 64-character hex string
- Content type: JSON
Installation record for later verification and cleanup.
2. Database Record Creation
AnInstallation record is persisted with:
3. Background Tasks (Async)
Two tasks are queued in the background: Project Scanner (scan_repo):
- Fetches the repository file tree from GitHub
- Analyzes project structure and dependencies
- Identifies language, framework, and key files
build_repo_graph):
- Creates a Neo4j knowledge graph of the codebase
- Indexes files with language and size metadata
- Establishes
Repository-[:CONTAINS]->Filerelationships
Error Responses
Repository is already connected
JWT token is invalid, expired, or missing
GitHub OAuth token cannot be decrypted (SECRET_KEY changed)
Failed to install webhook on GitHubCommon causes:
- User lacks admin permissions on the repository
- OAuth token missing
reposcope - GitHub API is unavailable
Permissions Required
GitHub OAuth Scopes
repo- Required to create webhooks and access repository contents
Repository Access
The authenticated user must have admin permissions on the repository to install webhooks.Related Endpoints
- List Repositories - View all repositories with connection status
- Disconnect Repository - Remove webhook and deactivate connection
- Rescan Repository - Rebuild the code knowledge graph