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 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: If you use GitHub Enterprise, set up an enterprise connection (PAT or enterprise GitHub App). The organization-level connection is only for organizations that are not part of a GitHub Enterprise. Per-user AI credit data for enterprise-owned organizations must be imported via an enterprise connection—the org-level endpoint cannot filter usage by user for enterprise-owned organizations.
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—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 (enterprise admin). The billing usage report export requires an enterprise admin—billing managers cannot create report exports.
- a classic PAT with the
manage_billing:enterprisescope - allowlist DX IP addresses 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_errorconnection 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 to register and install the app
- allowlist DX IP addresses 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_errorconnection issues.
For organization-level connections (GitHub App):
- a GitHub user account that is an Organization owner or billing manager
- the organization must have access to the enhanced billing platform
- allowlist DX IP addresses 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 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.
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 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.

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.

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.

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. 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.
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, 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 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.
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 (org, GitHub App) |
| /organizations/{org}/settings/billing/ai_credit/usage | Link (org, GitHub App) |
| POST /enterprises/{enterprise}/settings/billing/reports | Link (enterprise, PAT or GitHub App) |
| GET /enterprises/{enterprise}/settings/billing/reports/ | Link (enterprise, PAT or GitHub App) |
| GET /enterprises/{enterprise}/settings/billing/reports | Link (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 (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 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 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:
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'
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 for the enterprise installation:
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'
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.