---
title: "GitHub Copilot Billing"
canonical_url: "https://docs.getdx.com/connectors/github-copilot-billing/"
md_url: "https://docs.getdx.com/connectors/github-copilot-billing.md"
last_updated: "2026-11-13"
---

# GitHub Copilot Billing
By enabling the GitHub Copilot Billing connector, you can import GitHub's usage-based billing data for Copilot. Please refer to the API documentation below and our [schema explorer](https://docs.getdx.com/schema/) to see what data DX imports—note that DX does not read or access your source code.

DX only imports **Copilot** billing rows (the `copilot` product) from the GitHub billing usage report; other products such as Actions, Packages, and Git LFS are ignored. The connector supports both **enterprise-level** and **organization-level** (non-enterprise) billing, depending on the authentication method you choose.

All data is imported into the `github_copilot_billing_usages` table. Enterprise data is identified by `enterprise_slug`; org-level data is identified by `organization_id`.

> **Note**: Choose the connection type that matches how your GitHub account is set up:
>
> - **Your organizations belong to a GitHub enterprise account**: use the **Enterprise** connection type, with a personal access token (Option 1) or an enterprise GitHub App (Option 2).
> - **Your organizations are standalone, with no enterprise account**: use the **Organization** connection type with a GitHub App (Option 3).
>
> Don't use the Organization connection type for organizations that belong to an enterprise. GitHub does not let an organization-level GitHub App filter AI credit usage by user for those organizations, and rejects the request with `403 "Organization admins for enterprise owned organizations cannot filter usage by user"`.

## Authentication methods

The GitHub Copilot Billing connector supports two authentication methods:

- **Personal Access Token (PAT)**: For **enterprise** connections. Reads the AI credit usage report export.
- **GitHub App**: For both **enterprise** and **organization** (non-enterprise) connections.

For **enterprise** connections you can use either a PAT or a GitHub App. Both read AI credit usage via GitHub's asynchronous [usage report export API](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage-reports)—a PAT authenticates directly, while a GitHub App uses an installation access token from an enterprise-level installation.

For **organization** (non-enterprise) connections, DX iterates over your GitHub App installations and pulls the usage report per organization using `GET /organizations/{org}/settings/billing/usage`.

## Prerequisites

**For enterprise-level connections (PAT):**

- a GitHub user account that is an [Enterprise Owner](https://docs.github.com/en/enterprise-cloud@latest/admin/managing-accounts-and-repositories/managing-users-in-your-enterprise/roles-in-an-enterprise#enterprise-owners) (enterprise admin). The billing usage report export requires an enterprise admin—billing managers cannot create report exports.
- a classic PAT with the `manage_billing:enterprise` scope
- allowlist [DX IP addresses](https://docs.getdx.com/allowlisting-dx/) if your GitHub instance is behind a firewall or has IP restrictions. IP allowlisting must be configured at the enterprise level, not just the org-level, to avoid `internal_error` connection issues.

**For enterprise-level connections (GitHub App):**

- a GitHub App installed at the **enterprise** level with at least one of the enterprise permissions required by the billing usage report export API: **Enterprise billing** set to **Read-only** (recommended, least privilege) or **Enterprise administration** set to **Read and write**
- a GitHub user account that is an [Enterprise Owner](https://docs.github.com/en/enterprise-cloud@latest/admin/managing-accounts-and-repositories/managing-users-in-your-enterprise/roles-in-an-enterprise#enterprise-owners) to register and install the app
- allowlist [DX IP addresses](https://docs.getdx.com/allowlisting-dx/) if your GitHub instance is behind a firewall or has IP restrictions. IP allowlisting must be configured at the enterprise level, not just the org-level, to avoid `internal_error` connection issues.

**For organization-level connections (GitHub App):**

- a GitHub user account that is an [Organization owner](https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#organization-owners) or billing manager
- the organization must have access to the [enhanced billing platform](https://docs.github.com/en/billing/using-the-new-billing-platform/about-the-billing-platform)
- allowlist [DX IP addresses](https://docs.getdx.com/allowlisting-dx/) if your GitHub instance is behind a firewall or has IP restrictions

## Setup instructions

Follow the steps below to connect GitHub to DX using your preferred authentication method.

### Option 1: Enterprise Personal Access Token (PAT)

This method reads the enterprise AI credit usage report export.

#### Step 1

While signed into GitHub as an **Enterprise Owner** (enterprise admin—billing managers cannot create report exports), navigate to **Settings > Developer Settings > Personal Access Token**.

#### Step 2

Click on **Token (classic) > Generate new token (Classic)**. The `manage_billing:enterprise` scope is required.

#### Step 3

- Navigate to the connections page in DX and select "+ Connection" in the top right.
- Choose **GitHub Copilot Billing**, select the **Enterprise** connection type, choose **Personal access token (PAT)** as the authentication method, and enter your enterprise slug and the token you generated—refer to the information below for errors and troubleshooting.

### Option 2: Enterprise GitHub App

This method reads enterprise **AI credit usage** via the billing usage report export API using an enterprise installation token.

#### Step 1

As an Enterprise Owner, register a GitHub App owned by your enterprise: in your enterprise account, go to **Settings > GitHub Apps > New GitHub App**. Give it a name (e.g. **[COMPANYNAME] DX - GitHub Copilot Billing**) and set `https://getdx.com` as the homepage URL. Disable the webhook.

#### Step 2

In the **Permissions** tab, under **Enterprise permissions**, set **one** of the following:

| Scope      | Permission                | Access                         |
| ---------- | ------------------------- | ------------------------------ |
| Enterprise | Enterprise billing        | Read-only _(recommended)_      |
| Enterprise | Enterprise administration | Read and write _(alternative)_ |

The [billing usage report export API](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage-reports?apiVersion=2026-03-10#create-a-usage-report-export) accepts either **Enterprise billing** (read) or **Enterprise administration** (write). Grant **Enterprise billing (read)** if it is available on your enterprise—it is the least-privilege option and all DX needs.

#### Step 3

Click **Create GitHub App**. On the next screen, copy the **App ID** shown at the top, then scroll to **Private keys** and click **Generate a private key** to download a PEM file. Copy its contents for use in DX later.

#### Step 4

Click **Install App** in the sidebar and install the app on your **enterprise** account.

#### Step 5

Navigate to the connections page in DX and select "+ Connection" in the top right. Choose **GitHub Copilot Billing**, select the **Enterprise** connection type, choose **GitHub App** as the authentication method, and enter your enterprise slug, App ID, and private key.

### Option 3: Organization GitHub App (non-enterprise)

This method is for organizations that do not use GitHub Enterprise. It provides access to the org-level billing usage report. Follow the full [GitHub App registration and installation process](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app).

#### Step 1

Browse to the URL below with ORGANIZATION_NAME replaced:

```
https://github.com/organizations/ORGANIZATION_NAME/settings/apps/new?public=false&url=https://getdx.com&request_oauth_on_install=false&setup_on_update=false&webhook_active=false
```

#### Step 2

This will pre-populate settings. Enter a name for your GitHub App (e.g. **[COMPANYNAME] DX - GitHub Copilot Billing**). In the **Permissions & events** tab, set the following permission:

| Scope        | Permission     | Description            |
| ------------ | -------------- | ---------------------- |
| Organization | Administration | Read-only _(required)_ |

See [GitHub's billing usage documentation](https://docs.github.com/en/rest/billing/usage?apiVersion=2022-11-28#get-billing-usage-report-for-an-organization) for details.

#### Step 3

Scroll to the bottom of the page and click **Create GitHub App**.

#### Step 4

The GitHub App ID will be shown at the top of the subsequent screen. Copy this ID for use in DX later.

![](https://docs.getdx.com/assets/images/connectors/github/github-app.png){class="max-w-xl mx-auto"}

#### Step 5

On the same screen, scroll down to **Private keys** and click **Generate a private key** to download a PEM file. Copy the contents of this file for use in DX later.

![](https://docs.getdx.com/assets/images/connectors/github/private-key.png){class="max-w-xl mx-auto"}

#### Step 6

Click **Install App** in the sidebar, then click **Install** beside each organization where you want Copilot billing data. No enterprise installation is required.

![](https://docs.getdx.com/assets/images/connectors/github/repository-access.png){class="max-w-xl mx-auto"}

#### Step 7

Navigate to the connections page in DX and select "+ Connection" in the top right. Choose **GitHub Copilot Billing**, select the **Organization** connection type, and enter your App ID and private key.

## Data availability

The GitHub Copilot Billing connector imports Copilot billing usage and Copilot AI credit usage, including gross, discount, and net billing amounts.

For **enterprise** connections (PAT **or** GitHub App), AI credit usage is imported via GitHub's asynchronous [usage report export API](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage-reports). DX requests an `ai_credit` report for a date range, polls until it completes, then downloads the CSV and imports it broken down by user, day, model, organization, and repository. Each import refreshes the most recent day and backfills history in 15-day windows.

Enterprise connections can also see uncached input, output, cache-read, and cache-write token counts in DX. Each token category is imported when GitHub reports it, and unavailable values are left blank. These detailed token fields are available for **GitHub Enterprise Cloud** users, including GitHub Enterprise Cloud with data residency on GHE.com, when the enterprise connection has permission to use the report export API. These detailed report token fields are not available through organization-only connections or self-hosted **GitHub Enterprise Server** instances.

For **organization (GitHub App)** connections, AI credit usage is imported by user by day via the `ai_credit/usage` endpoint when GitHub's API supports per-user filtering.

In [AI cost management](https://docs.getdx.com/reports/ai-cost-management/), Copilot estimated cost uses gross AI credit spend before discounts or included credits are netted out. To attribute that cost by team, group, or contributor, DX also needs daily usage data from the [GitHub Copilot Metrics](https://docs.getdx.com/connectors/github-copilot-metrics/) connector for the same scope, users, and dates. An enterprise Billing connection pairs with enterprise-scoped Metrics for the same enterprise. In that configuration, Copilot token totals use input, output, cache-read, and cache-write values when GitHub reports them. Input and output fall back to Copilot CLI totals when report values are unavailable. Organization-scoped Metrics retain Copilot CLI prompt and output tokens and do not receive the enterprise report's cache-token data.

Copilot estimated cost is a usage allocation view for budgeting and forecasting. It may not match the final Copilot invoice after discounts or pooled included credits.

## API reference

The table below lists the specific API endpoints that are used by DX.


| Endpoint | Reference |
|----------------------------------------------------------------|-----------|
| /organizations/{org}/settings/billing/usage | [Link](https://docs.github.com/en/rest/billing/usage?apiVersion=2022-11-28#get-billing-usage-report-for-an-organization) (org, GitHub App) |
| /organizations/{org}/settings/billing/ai_credit/usage | [Link](https://docs.github.com/en/rest/billing/usage?apiVersion=2022-11-28#get-billing-ai-credit-usage-report-for-an-organization) (org, GitHub App) |
| POST /enterprises/{enterprise}/settings/billing/reports | [Link](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage-reports) (enterprise, PAT or GitHub App) |
| GET /enterprises/{enterprise}/settings/billing/reports/{report_id} | [Link](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage-reports) (enterprise, PAT or GitHub App) |
| GET /enterprises/{enterprise}/settings/billing/reports | [Link](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage-reports) (enterprise, PAT or GitHub App) |


## Errors

The table below lists potential error codes when adding a connection in DX.


| Error | Description |
|----------------------|------------------------------------------------------------------------------------------------------------------|
| `invalid_credentials` | Your API credentials entered are not valid. |
| `invalid_permissions` | Your API token or GitHub App does not have the permissions required by DX. For enterprise (PAT): verify your service account is an [Enterprise Owner](https://docs.github.com/en/enterprise-cloud@latest/admin/managing-accounts-and-repositories/managing-users-in-your-enterprise/roles-in-an-enterprise#enterprise-owners) (enterprise admin—billing managers cannot create report exports) and that your token has the `manage_billing:enterprise` scope. For enterprise (GitHub App): verify the app is installed at the enterprise level with either **Enterprise billing (read)** or **Enterprise administration (write)**. For org-level: verify your GitHub App has **Organization: Administration (read)** and is installed to the organization. |
| `403` "Organization admins for enterprise owned organizations cannot filter usage by user" | The organization is owned by a GitHub Enterprise, and GitHub does not allow an organization-level GitHub App to filter its AI credit usage by user. Switch to an **Enterprise** connection (a PAT or an enterprise-level GitHub App) instead of the **Organization** connection. This is not a missing permission, so granting the app more permissions will not fix it. |
| "These organizations belong to a GitHub enterprise… Use an Enterprise connection instead." | GitHub answered `403 "Organization admins for enterprise owned organizations cannot filter usage by user"`. See the 403 row above: switch to an **Enterprise** connection. |
| "AI credit usage is not accessible for any installed organization" | DX could not read AI credit usage for any organization the GitHub App is installed on. The details show each organization and GitHub's response. If GitHub's response is `Resource not accessible by integration`, grant the app the **Organization: Administration (read)** permission and accept the permission update on each installation. |


## Curl commands

#### When connection verification fails

When DX verifies a GitHub Copilot Billing connection, it checks access to the relevant endpoint. If your connection is failing, you can test the endpoints directly using the curl commands below to troubleshoot the issue. Replace `YYYY`, `MM`, and `DD` with the date you want to inspect.

**Enterprise (PAT):** Replace `YOUR_ENTERPRISE_SLUG` with your enterprise slug and `YOUR_TOKEN` with your Personal Access Token.

**Org-level (GitHub App):** Replace `YOUR_ORG` with your organization login and `YOUR_INSTALLATION_TOKEN` with an [installation access token](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app) from your GitHub App.

#### 1. Test Organization Billing Usage Access (org-level)

For org-level connections, test the organization API. Replace `YOUR_ORG` with your organization login and `YOUR_INSTALLATION_TOKEN` with an installation access token:

<div class="code-block-wrapper">
  <button class="copy-button" title="Copy to clipboard">
    <svg class="copy-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
    <svg class="check-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>
  </button>
  <pre><code class="language-bash">curl -H 'Accept: application/vnd.github+json' -H 'Authorization: Bearer YOUR_INSTALLATION_TOKEN' -H 'X-GitHub-Api-Version: 2022-11-28' 'https://api.github.com/organizations/YOUR_ORG/settings/billing/usage?year=YYYY&month=MM&day=DD'</code></pre>
</div>

#### 2. Test Billing Usage Report Export Access (enterprise, PAT or GitHub App)

Enterprise AI credit usage is imported via the asynchronous usage report export. This lists the report exports for your enterprise and verifies that your token has the required permission (note the dated `X-GitHub-Api-Version` header). For a **PAT** connection use your Personal Access Token; for a **GitHub App** connection use an [installation access token](https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-an-installation-access-token-for-a-github-app) for the enterprise installation:

<div class="code-block-wrapper">
  <button class="copy-button" title="Copy to clipboard">
    <svg class="copy-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>
    <svg class="check-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>
  </button>
  <pre><code class="language-bash">curl -H 'Accept: application/vnd.github+json' -H 'Authorization: Bearer YOUR_TOKEN' -H 'X-GitHub-Api-Version: 2026-03-10' 'https://api.github.com/enterprises/YOUR_ENTERPRISE_SLUG/settings/billing/reports'</code></pre>
</div>

## Troubleshooting

#### I'm seeing "no_resource" error from API response

This indicates that you don't have billing access to the enterprise or organization account. Use the curl commands above to verify access to the required endpoints.

#### Billing has been connected but my data is incomplete for the current day

GitHub's billing usage totals for the current day are still accumulating, so org/enterprise-level values can lag until the day finalizes. DX re-fetches a recent window on each run, so these values update on subsequent imports.

#### "A usage report export is already in progress" (HTTP 409)

GitHub allows only one billing usage report export in progress per enterprise at a time. DX handles this automatically—it resumes the in-progress export when it matches the range being requested, otherwise it retries on the next import—so no action is needed. If you hit this while testing the export manually, wait for the current export to finish before requesting another.
---

## Sitemap

[Overview of all docs pages](/llms.txt)
