Skip to main content
DELETE
/
api
/
v1
/
repos
/
{owner}
/
{repo}
/
install
Disconnect Repository
curl --request DELETE \
  --url https://api.example.com/api/v1/repos/{owner}/{repo}/install
{
  "status": "<string>",
  "repo": "<string>"
}

Overview

Disconnects a repository from Nectr AI by removing the GitHub webhook and marking the installation as inactive. After disconnection, PR events from this repository will no longer trigger AI reviews.

Authentication

Requires a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Path Parameters

owner
string
required
Repository owner (user or organization)
repo
string
required
Repository name

Request

curl -X DELETE "https://api.nectr.ai/api/v1/repos/acme/my-backend/install" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Response

status
string
Always returns "disconnected" on success
repo
string
Full repository name in owner/repo format

Example Response

{
  "status": "disconnected",
  "repo": "acme/my-backend"
}

What Happens During Disconnection

1. Webhook Removal

If the installation has a webhook_id, the endpoint attempts to delete the webhook from GitHub using:
DELETE https://api.github.com/repos/{owner}/{repo}/hooks/{webhook_id}
Graceful Degradation: If webhook removal fails (e.g., webhook already deleted manually on GitHub, or user lost admin access), a warning is logged but the disconnection proceeds.

2. Installation Deactivation

The Installation record is marked as inactive:
installation.is_active = False
The record is not deleted from the database, preserving historical data.

3. Data Retention

Preserved:
  • Installation record (marked is_active = False)
  • Neo4j code graph (Repository, File, PullRequest, Developer nodes)
  • Historical PR review data
Effect:
  • No new webhook events will be processed
  • Repository will show as disconnected in /api/v1/repos
  • User can reconnect later without data loss

Error Responses

401 Unauthorized
JWT token is invalid, expired, or missing
{
  "detail": "Unauthorized"
}
401 Session Expired
GitHub OAuth token cannot be decrypted (SECRET_KEY changed)
{
  "detail": "Session expired — please log out and sign in again."
}
404 Not Found
No active installation found for this repository and user
{
  "detail": "Installation not found"
}
This can occur if:
  • The repository was never connected
  • The repository is already disconnected
  • The repository belongs to a different user

Webhook Removal Failure Scenarios

The endpoint handles webhook deletion gracefully:
ScenarioBehavior
Webhook deleted manually on GitHubWarning logged, disconnection succeeds
User lost admin permissionsWarning logged, disconnection succeeds
GitHub API unavailableWarning logged, disconnection succeeds
Network timeoutWarning logged, disconnection succeeds
In all cases, the installation is marked inactive, preventing future webhook events from being processed.

Permissions Required

GitHub OAuth Scopes

  • repo - Required to delete webhooks

Repository Access

The authenticated user must have admin permissions on the repository to remove webhooks. If permissions are lost, webhook removal will fail gracefully.

Reconnection

After disconnection, you can reconnect the same repository using the Connect Repository endpoint. The previous installation record will remain inactive, and a new active installation will be created.

Build docs developers (and LLMs) love