> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/Nectr-AI/nectr-ai-pr-review-agent/llms.txt
> Use this file to discover all available pages before exploring further.

# List Repositories

> Retrieve all GitHub repositories accessible to the authenticated user with connection status

## Overview

This endpoint fetches all GitHub repositories the user has access to and annotates them with their connection status to Nectr AI. The response includes repositories where the user is an owner, collaborator, or organization member.

## Authentication

Requires a valid JWT token in the `Authorization` header.

```
Authorization: Bearer <token>
```

## Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.nectr.ai/api/v1/repos" \
    -H "Authorization: Bearer YOUR_JWT_TOKEN"
  ```

  ```python Python theme={null}
  import httpx

  headers = {
      "Authorization": "Bearer YOUR_JWT_TOKEN"
  }

  response = httpx.get(
      "https://api.nectr.ai/api/v1/repos",
      headers=headers
  )
  repos = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.nectr.ai/api/v1/repos', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN'
    }
  });

  const repos = await response.json();
  ```
</CodeGroup>

## Response

Returns an array of repository objects with connection metadata.

<ResponseField name="repositories" type="array">
  Array of repository objects

  <ResponseField name="id" type="integer">
    GitHub repository ID
  </ResponseField>

  <ResponseField name="name" type="string">
    Repository name (without owner)
  </ResponseField>

  <ResponseField name="full_name" type="string">
    Full repository name in `owner/repo` format
  </ResponseField>

  <ResponseField name="description" type="string | null">
    Repository description from GitHub
  </ResponseField>

  <ResponseField name="private" type="boolean">
    Whether the repository is private
  </ResponseField>

  <ResponseField name="html_url" type="string">
    GitHub URL to the repository
  </ResponseField>

  <ResponseField name="updated_at" type="string">
    ISO 8601 timestamp of last repository update
  </ResponseField>

  <ResponseField name="is_connected" type="boolean">
    Whether this repository is connected to Nectr AI
  </ResponseField>

  <ResponseField name="installation_id" type="integer | null">
    Database ID of the installation record if connected, otherwise `null`
  </ResponseField>
</ResponseField>

### Example Response

```json theme={null}
[
  {
    "id": 123456789,
    "name": "my-backend",
    "full_name": "acme/my-backend",
    "description": "Production API backend",
    "private": true,
    "html_url": "https://github.com/acme/my-backend",
    "updated_at": "2026-03-10T14:32:10Z",
    "is_connected": true,
    "installation_id": 42
  },
  {
    "id": 987654321,
    "name": "frontend-app",
    "full_name": "acme/frontend-app",
    "description": null,
    "private": false,
    "html_url": "https://github.com/acme/frontend-app",
    "updated_at": "2026-03-08T09:15:22Z",
    "is_connected": false,
    "installation_id": null
  }
]
```

## Error Responses

<ResponseField name="401 Unauthorized">
  JWT token is invalid, expired, or missing

  ```json theme={null}
  {
    "detail": "Unauthorized"
  }
  ```
</ResponseField>

<ResponseField name="401 Session Expired">
  GitHub OAuth token cannot be decrypted (SECRET\_KEY changed)

  ```json theme={null}
  {
    "detail": "Session expired — please log out and sign in again to reconnect your GitHub account."
  }
  ```
</ResponseField>

<ResponseField name="502 Bad Gateway">
  Failed to fetch repositories from GitHub API

  ```json theme={null}
  {
    "detail": "Failed to fetch repositories from GitHub"
  }
  ```
</ResponseField>

## Implementation Details

### GitHub API Pagination

The endpoint automatically handles GitHub API pagination, fetching up to 100 repositories per page until all accessible repositories are retrieved.

### Repository Filtering

Repositories are fetched with the following GitHub API parameters:

* `affiliation`: `owner,collaborator,organization_member`
* `sort`: `updated` (most recently updated first)
* `per_page`: `100`

### Connection Status

The `is_connected` field is determined by checking for an active `Installation` record in the database where:

* `user_id` matches the current user
* `repo_full_name` matches the repository
* `is_active` is `true`
