> ## Documentation Index
> Fetch the complete documentation index at: https://docs.blackbox.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Disconnect GitHub

> Revoke and purge all stored GitHub tokens associated with your account. Clears both the database token and all GitHub-related cookies.

This endpoint permanently removes all GitHub tokens linked to your BLACKBOX account. After calling this endpoint, agent tasks that require GitHub access will fail until you reconnect via `POST /api/v1/git/config`.

<Warning>
  This action is **irreversible**. All stored GitHub tokens will be deleted. You will need to provide a new GitHub personal access token to re-enable repository access.
</Warning>

<Note>
  This endpoint requires a **Pro subscription**.
</Note>

## Authentication

To use this API, you need a BLACKBOX API Key. Follow these steps to get your API key:

1. Go to [app.blackbox.ai/agent-api](https://app.blackbox.ai/agent-api) and click **Get an API Key** (requires a Pro subscription)
2. Once provisioning completes, you will be redirected to your [Dashboard](https://app.blackbox.ai/dashboard)
3. From the Dashboard, create an API key to use with all Agent API requests

Your API key will be in the format: `sk-xxxxxxxxxxxxxxxxxxxxxx`

## Headers

<ParamField header="Authorization" type="string" required>
  API Key of the form `Bearer <api_key>`.

  Example: `Bearer sk_b41b647ffbfed27f616560`
</ParamField>

## Response Fields

<ResponseField name="success" type="boolean">
  `true` when all tokens were purged successfully.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable confirmation message.
</ResponseField>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  curl -X DELETE 'https://agent.blackbox.ai/api/v1/git/clean' \
    -H 'Authorization: Bearer YOUR_API_KEY'
  ```

  ```javascript Node.js theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  const API_KEY = "YOUR_API_KEY";

  const response = await fetch(
    "https://agent.blackbox.ai/api/v1/git/clean",
    {
      method: "DELETE",
      headers: { Authorization: `Bearer ${API_KEY}` },
    }
  );

  const data = await response.json();
  console.log(data.message);
  ```

  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import requests

  API_KEY = "YOUR_API_KEY"

  response = requests.delete(
      "https://agent.blackbox.ai/api/v1/git/clean",
      headers={"Authorization": f"Bearer {API_KEY}"},
  )
  data = response.json()
  print(data["message"])
  ```

  ```go Go theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  package main

  import (
      "encoding/json"
      "fmt"
      "io"
      "net/http"
  )

  func main() {
      apiKey := "YOUR_API_KEY"
      url := "https://agent.blackbox.ai/api/v1/git/clean"

      req, _ := http.NewRequest("DELETE", url, nil)
      req.Header.Set("Authorization", "Bearer "+apiKey)

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      body, _ := io.ReadAll(resp.Body)
      var result map[string]interface{}
      json.Unmarshal(body, &result)
      fmt.Println(result["message"])
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  {
    "success": true,
    "message": "GitHub access tokens purged successfully"
  }
  ```
</ResponseExample>

## Error Codes

| Status Code | Error                 | Description                |
| ----------- | --------------------- | -------------------------- |
| 200         | Success               | All GitHub tokens purged   |
| 401         | Unauthorized          | Invalid or missing API key |
| 403         | Forbidden             | Pro subscription required  |
| 500         | Internal Server Error | Failed to purge tokens     |
