---
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-06-11"
---

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

## Authentication methods

The GitHub Copilot Billing connector supports two authentication methods:

- **Personal Access Token (PAT)**: Provides access to the enterprise billing usage report. _Enterprise only._
- **GitHub App (Organization)**: Provides access to the organization billing usage report. _For non-enterprise customers or org-level data._

Enterprise billing can only be read with a PAT—GitHub Apps cannot access enterprise billing. For organization-level billing, 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) or billing manager
- 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: Personal Access Token (PAT)

This method provides access to the enterprise billing usage report.

#### Step 1

While signed into GitHub as an Enterprise Owner, 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, and enter your enterprise slug and the token you generated—refer to the information below for errors and troubleshooting.

### Option 2: 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. AI credit usage is imported by user by day when GitHub's API supports per-user filtering.

In [AI cost management](https://docs.getdx.com/reports/ai-cost-management/), Copilot AI credit usage provides estimated Copilot cost. To attribute that cost by team, group, or contributor, DX also needs [GitHub Copilot Metrics](https://docs.getdx.com/connectors/github-copilot-metrics/) daily usage data for the same users and dates. Copilot token totals come from GitHub Copilot Metrics and only reflect Copilot CLI prompt and output token usage.

## API reference

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


| Endpoint | Reference |
|----------------------------------------------------------------|-----------|
| /enterprises/{enterprise}/settings/billing/usage | [Link](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage?apiVersion=2022-11-28#get-billing-usage-report-for-an-enterprise) (PAT only, enterprise) |
| /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) (GitHub App, org-level only) |
| /enterprises/{enterprise}/settings/billing/ai_credit/usage | [Link](https://docs.github.com/en/enterprise-cloud@latest/rest/billing/usage?apiVersion=2022-11-28#get-billing-ai-credit-usage-report-for-an-enterprise) (PAT only, enterprise; supports per-user filtering) |
| /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) (GitHub App, org-level; per-user filtering not allowed for enterprise-owned orgs) |


## 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: 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) or billing manager and that your token has the `manage_billing:enterprise` scope. 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 org-level AI credit usage endpoint does not allow filtering by user when the organization is owned by an enterprise. Per-user AI credit data for enterprise-owned organizations must be imported via an **enterprise (PAT)** connection instead of a GitHub App (organization) connection. |


## 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 Enterprise Billing Usage Access (enterprise PAT only)

This verifies that your token can access the enterprise billing usage report:

<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: 2022-11-28' 'https://api.github.com/enterprises/YOUR_ENTERPRISE_SLUG/settings/billing/usage?year=YYYY&month=MM&day=DD'</code></pre>
</div>

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

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

## Sitemap

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