Copilot 企业版
使用 REST API 管理组织的 GitHub Copilot Business 订阅。
注意:GitHub Copilot Business API 终结点为公共 beta 版,可能会有所变化。
Get Copilot for Business seat information and settings for an organization
Note: This endpoint is in beta and is subject to change.
Gets information about an organization's Copilot for Business subscription, including seat breakdown and code matching policies. To configure these settings, go to your organization's settings on GitHub.com. For more information, see "Configuring GitHub Copilot settings in your organization".
Only organization owners and members with admin permissions can configure and view details about the organization's Copilot for Business subscription. You must
authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
Parameters for "Get Copilot for Business seat information and settings for an organization"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
HTTP response status codes for "Get Copilot for Business seat information and settings for an organization"
Status code | Description |
---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
500 | Internal Error |
Code samples for "Get Copilot for Business seat information and settings for an organization"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/copilot/billing
OK
Status: 200
{
"seat_breakdown": {
"total": 12,
"added_this_cycle": 9,
"pending_invitation": 0,
"pending_cancellation": 0,
"active_this_cycle": 12,
"inactive_this_cycle": 11
},
"seat_management_setting": "assign_selected",
"public_code_suggestions": "block"
}
List all Copilot for Business seat assignments for an organization
Note: This endpoint is in beta and is subject to change.
Lists all Copilot for Business seat assignments for an organization that are currently being billed (either active or pending cancellation at the start of the next billing cycle).
Only organization owners and members with admin permissions can configure and view details about the organization's Copilot for Business subscription. You must
authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
Parameters for "List all Copilot for Business seat assignments for an organization"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
名称, 类型, 说明 |
---|
page integer Page number of the results to fetch. 默认: |
per_page integer The number of results per page (max 100). 默认: |
HTTP response status codes for "List all Copilot for Business seat assignments for an organization"
Status code | Description |
---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
500 | Internal Error |
Code samples for "List all Copilot for Business seat assignments for an organization"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/copilot/billing/seats
Response
Status: 200
{
"total_seats": 2,
"seats": [
{
"created_at": "2021-08-03T18:00:00-06:00",
"updated_at": "2021-09-23T15:00:00-06:00",
"pending_cancellation_date": null,
"last_activity_at": "2021-10-14T00:53:32-06:00",
"last_activity_editor": "vscode/1.77.3/copilot/1.86.82",
"assignee": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"assigning_team": {
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://api.github.com/teams/1",
"html_url": "https://github.com/orgs/github/teams/justice-league",
"name": "Justice League",
"slug": "justice-league",
"description": "A great team.",
"privacy": "closed",
"notification_setting": "notifications_enabled",
"permission": "admin",
"members_url": "https://api.github.com/teams/1/members{/member}",
"repositories_url": "https://api.github.com/teams/1/repos",
"parent": null
}
},
{
"created_at": "2021-09-23T18:00:00-06:00",
"updated_at": "2021-09-23T15:00:00-06:00",
"pending_cancellation_date": "2021-11-01",
"last_activity_at": "2021-10-13T00:53:32-06:00",
"last_activity_editor": "vscode/1.77.3/copilot/1.86.82",
"assignee": {
"login": "octokitten",
"id": 1,
"node_id": "MDQ76VNlcjE=",
"avatar_url": "https://github.com/images/error/octokitten_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octokitten",
"html_url": "https://github.com/octokitten",
"followers_url": "https://api.github.com/users/octokitten/followers",
"following_url": "https://api.github.com/users/octokitten/following{/other_user}",
"gists_url": "https://api.github.com/users/octokitten/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octokitten/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octokitten/subscriptions",
"organizations_url": "https://api.github.com/users/octokitten/orgs",
"repos_url": "https://api.github.com/users/octokitten/repos",
"events_url": "https://api.github.com/users/octokitten/events{/privacy}",
"received_events_url": "https://api.github.com/users/octokitten/received_events",
"type": "User",
"site_admin": false
}
}
]
}
Add teams to the Copilot for Business subscription for an organization
Note: This endpoint is in beta and is subject to change.
Purchases a GitHub Copilot for Business seat for all users within each specified team. The organization will be billed accordingly. For more information about Copilot for Business pricing, see "About billing for GitHub Copilot for Business".
Only organization owners and members with admin permissions can configure GitHub Copilot in their organization. You must
authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
In order for an admin to use this endpoint, the organization must have a Copilot for Business subscription and a configured suggestion matching policy. For more information about setting up a Copilot for Business subscription, see "Setting up a Copilot for Business subscription for your organization". For more information about setting a suggestion matching policy, see "Configuring suggestion matching policies for GitHub Copilot in your organization".
Parameters for "Add teams to the Copilot for Business subscription for an organization"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
名称, 类型, 说明 |
---|
selected_teams array of strings 必须List of team names within the organization to which to grant access to GitHub Copilot. |
HTTP response status codes for "Add teams to the Copilot for Business subscription for an organization"
Status code | Description |
---|---|
201 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Copilot for Business is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, or the organization's Copilot access setting is set to enable Copilot for all users or is unconfigured. |
500 | Internal Error |
Code samples for "Add teams to the Copilot for Business subscription for an organization"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/copilot/billing/selected_teams \
-d '{"selected_teams":["engteam1","engteam2","engteam3"]}'
OK
Status: 201
{
"seats_created": 5
}
Remove teams from the Copilot for Business subscription for an organization
Note: This endpoint is in beta and is subject to change.
Cancels the Copilot for Business seat assignment for all members of each team specified. This will cause the members of the specified team(s) to lose access to GitHub Copilot at the end of the current billing cycle, and the organization will not be billed further for those users.
For more information about Copilot for Business pricing, see "About billing for GitHub Copilot for Business".
For more information about disabling access to Copilot for Business, see "Disabling access to GitHub Copilot for specific users in your organization".
Only organization owners and members with admin permissions can configure GitHub Copilot in their organization. You must
authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
Parameters for "Remove teams from the Copilot for Business subscription for an organization"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
名称, 类型, 说明 |
---|
selected_teams array of strings 必须The names of teams from which to revoke access to GitHub Copilot. |
HTTP response status codes for "Remove teams from the Copilot for Business subscription for an organization"
Status code | Description |
---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Copilot for Business is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, or the organization's Copilot access setting is set to enable Copilot for all users or is unconfigured. |
500 | Internal Error |
Code samples for "Remove teams from the Copilot for Business subscription for an organization"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/copilot/billing/selected_teams \
-d '{"selected_teams":["engteam1","engteam2","engteam3"]}'
OK
Status: 200
{
"seats_cancelled": 5
}
Add users to the Copilot for Business subscription for an organization
Note: This endpoint is in beta and is subject to change.
Purchases a GitHub Copilot for Business seat for each user specified. The organization will be billed accordingly. For more information about Copilot for Business pricing, see "About billing for GitHub Copilot for Business".
Only organization owners and members with admin permissions can configure GitHub Copilot in their organization. You must
authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
In order for an admin to use this endpoint, the organization must have a Copilot for Business subscription and a configured suggestion matching policy. For more information about setting up a Copilot for Business subscription, see "Setting up a Copilot for Business subscription for your organization". For more information about setting a suggestion matching policy, see "Configuring suggestion matching policies for GitHub Copilot in your organization".
Parameters for "Add users to the Copilot for Business subscription for an organization"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
名称, 类型, 说明 |
---|
selected_usernames array of strings 必须The usernames of the organization members to be granted access to GitHub Copilot. |
HTTP response status codes for "Add users to the Copilot for Business subscription for an organization"
Status code | Description |
---|---|
201 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Copilot for Business is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, or the organization's Copilot access setting is set to enable Copilot for all users or is unconfigured. |
500 | Internal Error |
Code samples for "Add users to the Copilot for Business subscription for an organization"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/copilot/billing/selected_users \
-d '{"selected_usernames":["cooluser1","hacker2","octocat"]}'
OK
Status: 201
{
"seats_created": 5
}
Remove users from the Copilot for Business subscription for an organization
Note: This endpoint is in beta and is subject to change.
Cancels the Copilot for Business seat assignment for each user specified. This will cause the specified users to lose access to GitHub Copilot at the end of the current billing cycle, and the organization will not be billed further for those users.
For more information about Copilot for Business pricing, see "About billing for GitHub Copilot for Business"
For more information about disabling access to Copilot for Business, see "Disabling access to GitHub Copilot for specific users in your organization".
Only organization owners and members with admin permissions can configure GitHub Copilot in their organization. You must
authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
Parameters for "Remove users from the Copilot for Business subscription for an organization"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
名称, 类型, 说明 |
---|
selected_usernames array of strings 必须The usernames of the organization members for which to revoke access to GitHub Copilot. |
HTTP response status codes for "Remove users from the Copilot for Business subscription for an organization"
Status code | Description |
---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Copilot for Business is not enabled for this organization, billing has not been set up for this organization, a public code suggestions policy has not been set for this organization, the seat management setting is set to enable Copilot for all users or is unconfigured, or a user's seat cannot be cancelled because it was assigned to them via a team. |
500 | Internal Error |
Code samples for "Remove users from the Copilot for Business subscription for an organization"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/copilot/billing/selected_users \
-d '{"selected_usernames":["cooluser1","hacker2","octocat"]}'
OK
Status: 200
{
"seats_cancelled": 5
}
Get Copilot for Business seat assignment details for a user
Note: This endpoint is in beta and is subject to change.
Gets the GitHub Copilot for Business seat assignment details for a member of an organization who currently has access to GitHub Copilot.
Organization owners and members with admin permissions can view GitHub Copilot seat assignment details for members in their organization. You must authenticate using an access token with the manage_billing:copilot
scope to use this endpoint.
Parameters for "Get Copilot for Business seat assignment details for a user"
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
org string 必须The organization name. The name is not case sensitive. |
username string 必须The handle for the GitHub user account. |
HTTP response status codes for "Get Copilot for Business seat assignment details for a user"
Status code | Description |
---|---|
200 | The user's GitHub Copilot seat details, including usage. |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
422 | Copilot for Business is not enabled for this organization or the user has a pending organization invitation. |
500 | Internal Error |
Code samples for "Get Copilot for Business seat assignment details for a user"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/members/USERNAME/copilot
The user's GitHub Copilot seat details, including usage.
Status: 200
{
"created_at": "2021-08-03T18:00:00-06:00",
"updated_at": "2021-09-23T15:00:00-06:00",
"pending_cancellation_date": null,
"last_activity_at": "2021-10-14T00:53:32-06:00",
"last_activity_editor": "vscode/1.77.3/copilot/1.86.82",
"assignee": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"assigning_team": {
"id": 1,
"node_id": "MDQ6VGVhbTE=",
"url": "https://api.github.com/teams/1",
"html_url": "https://github.com/orgs/github/teams/justice-league",
"name": "Justice League",
"slug": "justice-league",
"description": "A great team.",
"privacy": "closed",
"notification_setting": "notifications_enabled",
"permission": "admin",
"members_url": "https://api.github.com/teams/1/members{/member}",
"repositories_url": "https://api.github.com/teams/1/repos",
"parent": null
}
}