> ## 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.

# Get GitHub Organizations

> Retrieve all GitHub organizations associated with the authenticated user's account.

This endpoint returns a list of all GitHub organizations that the authenticated user has access to, including organization details such as name, login, and avatar.

## Authentication

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

1. **Click on your Profile Image** in the top right corner at [cloud.blackbox.ai](https://cloud.blackbox.ai)
2. **Click on "BLACKBOX API Token"** from the dropdown menu
3. **Copy the existing token** or **click "Generate"** if you don't have one yet

Your API key will be in the format: `bb_xxxxxxxxxxxxxxxxxxxxxx`

## Headers

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

  Example: `Bearer bb_b41b647ffbfed27f61656049d3eaeef3d903cc503345d9eb80080d98bc0`
</ParamField>

## Response

The endpoint returns an array of organization objects.

<ResponseField name="login" type="string">
  The organization's GitHub username/login identifier.
</ResponseField>

<ResponseField name="name" type="string">
  The display name of the organization.
</ResponseField>

<ResponseField name="avatar_url" type="string">
  URL to the organization's avatar image.
</ResponseField>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  curl --location 'https://cloud.blackbox.ai/api/github/orgs' \
  --header '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 API_URL = "https://cloud.blackbox.ai/api/github/orgs";

  const response = await fetch(API_URL, {
      method: "GET",
      headers: {
          Authorization: `Bearer ${API_KEY}`,
      },
  });

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

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

  API_KEY = "YOUR_API_KEY"
  API_URL = "https://cloud.blackbox.ai/api/github/orgs"

  headers = {
      "Authorization": f"Bearer {API_KEY}"
  }

  response = requests.get(API_URL, headers=headers)
  organizations = response.json()
  print(organizations)
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  [
      {
          "login": "example-org",
          "name": "Example Organization",
          "avatar_url": "https://avatars.githubusercontent.com/u/12345678?v=4"
      },
      {
          "login": "another-org",
          "name": "Another Organization",
          "avatar_url": "https://avatars.githubusercontent.com/u/87654321?v=4"
      }
  ]
  ```

  ```json Error Response theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  {
    "error": "Unauthorized",
    "message": "Invalid or missing API key",
    "status": 401
  }
  ```
</ResponseExample>

## Error Codes

| Status Code | Error                 | Description                          |
| ----------- | --------------------- | ------------------------------------ |
| 200         | Success               | Organizations retrieved successfully |
| 401         | Unauthorized          | Invalid or missing API key           |
| 404         | Not Found             | GitHub token not found or expired    |
| 502         | Bad Gateway           | GitHub API error occurred            |
| 500         | Internal Server Error | Database or server error occurred    |
