GitHub Copilot Metrics (Enterprise)
By enabling the GitHub Copilot connector, you can import user-level Copilot usage metrics. 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.
Before proceeding, please make sure that you have first enabled the GitHub connector by following the steps here. Each GitHub-related connection in DX should utilize a separate GitHub App or API token to avoid rate limit issues.
Prerequisites
To connect GitHub Commits to DX, you need:
- a GitHub user account that is an Enterprise Owner
- a Copilot metrics API access policy that is enabled
- 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.
Setup instructions
Follow the steps below to connect GitHub to DX.
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). Either the manage_billing:copilot or read:enterprise scope is required.
Step 3
- Navigate to the connections page in DX and select “+ Connection” in the top right.
- Enter the credentials you have generated in the previous steps—refer to the information below for errors and troubleshooting.
API reference
The table below lists the specific API endpoints that are used by DX. Please note that, to access these API endpoint, your Copilot Metrics API access policy must be enabled or set to “no policy” for your enterprise.
*Note: the /user-engagement endpoint is behind an Early Access program with GitHub. If your enterprise is not enrolled in that preview, the GitHub API will return a 404 Not Found instead.
| Endpoint | Reference |
|---|---|
| /enterprises/{enterprise}/copilot/billing/seats | Link |
| /enterprises/{enterprise}/copilot/metrics | Link |
| /enterprises/{enterprise}/copilot/user-engagement | Link |
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 does not have the permissions required by DX—please verify that your service account is an Enterprise Owner. |
Curl commands
When connection verification fails
When DX verifies a GitHub Copilot connection, it checks access to seat assignments. If your connection is failing, you can test the endpoints directly using the curl commands below to troubleshoot the issue. Replace YOUR_ENTERPRISE_SLUG with your enterprise slug and YOUR_TOKEN with your Personal Access Token.
1. Test Copilot Seat Assignments Access
This verifies that your token can access Copilot seat assignments:
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/copilot/billing/seats'
2. Test Copilot Metrics Access
This verifies that your token can access Copilot metrics:
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/copilot/metrics'
Troubleshooting
I’m seeing “no_resource” error from API response
This indicates that you don’t have admin access to the enterprise account. Use the curl commands above to verify access to the required endpoints.
Copilot has been connected but all of my reports are blank
This indicates that a Copilot metrics API access policy has not yet been enabled for your enterprise.