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

# GitHub

> Connect GitHub billing, usage, and seat data to nOps

## Overview

nOps uses a **GitHub personal access token (classic)** plus your **organization slug** and/or **enterprise slug** to pull billing, usage, and seat data into Inform. Credentials are stored securely, validated before save, and are not shown again after you connect.

nOps reads:

* **Cost & usage** — metered spend by product, SKU, repository, and day (Actions, Codespaces, Packages, Git LFS/Storage, Copilot, GHAS, ...).
* **Copilot attribution** — premium-request and AI-credit consumption per user and model, plus Copilot seat assignments.
* **Members & seats** — your organization member roster (paid user seats) and, for enterprise connections, per-user consumed licenses.

<Warning>
  nOps only accepts a **classic** personal access token. GitHub's billing usage endpoints do not accept other token types for either organization or enterprise connections.
</Warning>

<Note>
  Only **admins** and **owners** can connect, re-validate, or disconnect in nOps. **Members** see **Admin Only** on connectable cards.
</Note>

## Required access

The token owner must be an **organization owner or billing manager** (for org connections) and/or an **enterprise administrator or billing manager** (for enterprise connections). Your account must be on GitHub's **enhanced billing platform** (required for the billing usage REST endpoints). nOps organization **administrator** access is required to connect.

### Token scopes

Select these scopes when creating your classic PAT:

* `read:org` — organization billing/usage and member roster
* `manage_billing:copilot` — Copilot seats & billing *(only if you use Copilot)*
* `read:enterprise` — **required for enterprise connections** (enterprise billing usage and consumed licenses)

<Tip>
  Grant only what matches the data you want. Copilot and member scopes are optional — if omitted, nOps still pulls cost/usage and simply skips the datasets the token can't reach.
</Tip>

## Create the token

1. Sign in to [GitHub](https://github.com) as an org owner/billing manager or enterprise admin/billing manager.
2. Go to **Settings → Developer settings → Personal access tokens → Tokens (classic)**.
3. Click **Generate new token (classic)**, add a note (for example `nOps Integration`), and set an expiration.
4. Select **`read:org`**, **`manage_billing:copilot`** (if you use Copilot), and **`read:enterprise`** (for enterprise connections).
5. Generate and copy the token immediately — it is shown only once.

See [GitHub billing usage REST API](https://docs.github.com/en/rest/billing/usage) and [Automating usage reporting](https://docs.github.com/en/billing/tutorials/automate-usage-reporting) for endpoint and permission details.

## Connect in nOps

### Where to open GitHub

* **To connect for the first time** — go to **Settings → Integrations** and click the **GitHub** card.
* **To manage an existing connection** — go to **Settings → Account Status → Connected apps** and click the **GitHub** chip to re-validate or disconnect.

### Connect steps

1. Click the **GitHub** card or chip.
2. Paste your **classic personal access token**.
3. Enter your **Organization slug** and/or **Enterprise slug** (at least one is required).
4. Click **Connect**.

nOps validates the token with the GitHub API before storing it and rejects the connection with a clear error if validation fails. Billing data sync uses the slugs you provide to call the appropriate organization and/or enterprise endpoints.

## Manage your connection

Administrators can **Re-validate** or **Disconnect** from the modal. Rotate the token in GitHub before expiry and update the connection in nOps.

## Troubleshooting

* **Invalid token** — confirm the token owner has a billing role and the token is a classic PAT with the right scopes.
* **No enterprise data / 403 on enterprise** — regenerate a classic PAT with `read:enterprise` and an enterprise billing role.
* **No Copilot or member data** — add `manage_billing:copilot` / `read:org` to your classic PAT. Missing these skips those datasets but does not block cost/usage.
* **Missing org or enterprise** — enter at least one slug so nOps knows which account to report on.
* **No billing data** — your organization or enterprise may not yet be on the enhanced billing platform; verify in GitHub billing settings.
* **No data in Inform** — allow up to **24 hours** after connecting for the first sync.

## Security

Do not share the token or store it in public repositories. Grant only the scopes you need, rotate tokens on a regular schedule, and disconnect in nOps when rotating.

## Reference

* [GitHub REST API — Billing usage](https://docs.github.com/en/rest/billing/usage)
* [GitHub REST API — Copilot user management (seats)](https://docs.github.com/en/rest/copilot/copilot-user-management)
* [GitHub REST API — Enterprise consumed licenses](https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin/license)
* [Automating usage reporting with the REST API](https://docs.github.com/en/billing/tutorials/automate-usage-reporting)
