GitHub Copilot REST API via curl. Use this skill to manage Copilot subscriptions and retrieve usage metrics.
/plugin marketplace add vm0-ai/api0/plugin install api0@api0This skill inherits all available tools. When active, it can use any tool Claude has access to.
Use the GitHub Copilot REST API via direct curl calls to manage Copilot subscriptions and retrieve usage metrics for your organization.
Official docs:
https://docs.github.com/en/rest/copilot
Note: This API is for managing Copilot subscriptions and viewing metrics, not for code generation.
Use this skill when you need to:
manage_billing:copilot or admin:orgGITHUB_TOKENexport GITHUB_TOKEN="ghp_xxxxxxxxxxxx"
manage_billing:copilot - For billing and seat managementread:org - For reading organization dataadmin:org - For adding/removing users and teamsImportant: When using
$VARin a command that pipes to another command, wrap the command containing$VARinbash -c '...'. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq .
All examples below assume you have GITHUB_TOKEN set.
Base URL: https://api.github.com
Required headers:
Authorization: Bearer ${GITHUB_TOKEN}Accept: application/vnd.github+jsonX-GitHub-Api-Version: 2022-11-28Get seat breakdown and settings for an organization:
ORG="your-org-name"
bash -c 'curl -s -X GET "https://api.github.com/orgs/${ORG}/copilot/billing" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"' | jq .
Response:
{
"seat_breakdown": {
"total": 12,
"added_this_cycle": 2,
"pending_cancellation": 0,
"pending_invitation": 1,
"active_this_cycle": 12,
"inactive_this_cycle": 0
},
"seat_management_setting": "assign_selected",
"public_code_suggestions": "block"
}
Get all users with Copilot seats:
ORG="your-org-name"
bash -c 'curl -s -X GET "https://api.github.com/orgs/${ORG}/copilot/billing/seats?per_page=50" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"' | jq '.seats[] | {login: .assignee.login, last_activity: .last_activity_at}
Get specific user's Copilot seat information:
ORG="your-org-name"
USERNAME="octocat"
bash -c 'curl -s -X GET "https://api.github.com/orgs/${ORG}/members/${USERNAME}/copilot" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"' | jq .
Assign Copilot seats to specific users:
ORG="your-org-name"
bash -c 'curl -s -X POST "https://api.github.com/orgs/${ORG}/copilot/billing/selected_users" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d '"'"'{
"selected_usernames": ["user1", "user2"]
}'"'"' | jq .'
Response:
{
"seats_created": 2
}
Remove Copilot seats from specific users:
ORG="your-org-name"
bash -c 'curl -s -X DELETE "https://api.github.com/orgs/${ORG}/copilot/billing/selected_users" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d '"'"'{
"selected_usernames": ["user1", "user2"]
}'"'"' | jq .'
Response:
{
"seats_cancelled": 2
}
Assign Copilot to entire teams:
ORG="your-org-name"
bash -c 'curl -s -X POST "https://api.github.com/orgs/${ORG}/copilot/billing/selected_teams" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d '"'"'{
"selected_teams": ["engineering", "design"]
}'"'"' | jq .'
Remove Copilot from teams:
ORG="your-org-name"
bash -c 'curl -s -X DELETE "https://api.github.com/orgs/${ORG}/copilot/billing/selected_teams" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28" --header "Content-Type: application/json" -d '"'"'{
"selected_teams": ["engineering"]
}'"'"' | jq .'
Get usage statistics (requires 5+ active users):
ORG="your-org-name"
bash -c 'curl -s -X GET "https://api.github.com/orgs/${ORG}/copilot/metrics?per_page=7" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"' | jq '.[] | {date, total_active_users, total_engaged_users}
Response:
{
"date": "2024-06-24",
"total_active_users": 24,
"total_engaged_users": 20
}
Get team-specific usage metrics:
ORG="your-org-name"
TEAM="engineering"
bash -c 'curl -s -X GET "https://api.github.com/orgs/${ORG}/team/${TEAM}/copilot/metrics" --header "Authorization: Bearer ${GITHUB_TOKEN}" --header "Accept: application/vnd.github+json" --header "X-GitHub-Api-Version: 2022-11-28"' | jq .
The metrics response includes:
| Field | Description |
|---|---|
total_active_users | Users with Copilot activity |
total_engaged_users | Users who accepted suggestions |
copilot_ide_code_completions | Code completion stats by language/editor |
copilot_ide_chat | IDE chat usage stats |
copilot_dotcom_chat | GitHub.com chat usage |
copilot_dotcom_pull_requests | PR summary usage |