Copilot 团队自定义的 REST API 端点
使用 REST API 来管理团队的 Copilot 自定义。
关于 Copilot 团队自定义
Copilot自定义文档定义组织团队成员可用的插件和插件市场。 GitHub 为每个团队存储一个文档。 可以在团队的 “自定义Copilot” 选项卡上或使用这些终结点创建和管理文档。
自定义文档支持以下顶级键:
pluginAssignments:可供团队使用的插件,按PLUGIN@MARKETPLACE作为键。 默认情况下,每个插件都处于启用状态。extraKnownMarketplaces:可供团队使用的其他插件市场,以市场名称为键。
下面的请求和响应示例显示了一个插件及其应用市场。
访问要求
经过身份验证的用户必须是组织所有者或团队的维护者。 对于分配给组织的企业团队,包括与标识提供者组同步的企业团队,经过身份验证的用户必须是组织所有者。 除了这些角色要求之外,所需的范围和权限也是必需的。
| 令牌类型 | 查看自定义设置 | 替换或删除自定义项 |
|---|---|---|
| Personal access token (classic) 或 OAuth app 令牌 | read:org 或 admin:org 作用域 | admin:org 范围 |
| Fine-grained personal access token 或 GitHub App 用户访问令牌 | 具有读取权限的组织“Copilot 智能体设置”权限 | 具有写入访问权限的“Copilot 智能体 settings”组织权限 |
创建和更新自定义项
若要创建团队的自定义文档,请将完整文档作为 JSON 请求正文发送到 PUT 终结点。 不要将其包装在另一个对象中。 成功的请求会返回 200 OK,其中包含所提交的文档。
终结点 PUT 将替换整个文档。 它不会将请求与现有自定义项合并。 从请求中省略的任何插件或应用市场都将从存储的文档中删除。
编辑现有文档:
- 使用
GET终结点获取团队的当前自定义文档。 - 编辑文档,保留要保留的每个插件和应用市场。
- 将完整文档发送到
PUT终结点。
在替换文档之前读取文档不会阻止请求之间的另一次编辑。
当团队没有文档时,终结点 GET 将 404 Not Found 返回。 404 还可能意味着经过身份验证的用户无法访问该团队。
若要删除团队的自定义文档,请使用 DELETE 终结点。 即使文档不存在,它也会返回 204 No Content 。 这不会删除团队。
无效的文档返回 422 Unprocessable Entity,并说明原因。 并发编辑可能会导致写入或删除返回 409 Conflict。
Get Copilot customizations for a team
Gets the GitHub-managed Copilot customization document for an organization team.
Returns 404 if the team has no customization document. Enterprise teams are not supported.
The authenticated user must be an organization owner or a team maintainer. For an organization team managed by an enterprise team or SCIM-backed identity provider group, the authenticated user must be an organization owner. Token permissions do not grant access to teams the authenticated user cannot administer.
OAuth app tokens and personal access tokens (classic) need the admin:org or read:org scope to use this endpoint.
Fine-grained personal access tokens and GitHub App user access tokens need the organization's
"Copilot agent settings" permission with read access. GitHub App installation access tokens are not supported.
Returns 422 if the stored customization document cannot be read.
“Get Copilot customizations for a team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Copilot agent settings" organization permissions (read)
“”Get Copilot customizations for a team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
org string 必须The organization name. The name is not case sensitive. |
team_slug string 必须The slug of the team name. |
“Get Copilot customizations for a team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
409 | Conflict |
422 | Validation failed, or the endpoint has been spammed. |
500 | Internal Error |
503 | Service unavailable |
“Get Copilot customizations for a team”的代码示例
如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com。
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/copilot/customizationsResponse
Status: 200{
"pluginAssignments": {
"code-review@acme-marketplace": {
"state": "defaultEnabled"
}
},
"extraKnownMarketplaces": {
"acme-marketplace": {
"source": {
"source": "github",
"repo": "acme/copilot-marketplace"
}
}
}
}Set Copilot customizations for a team
Replaces the entire GitHub-managed Copilot customization document for an organization team, creating it on the first write. The request body is the customization document itself. Include every plugin assignment and marketplace you want to keep. Entries omitted from the request are removed from the stored document; this endpoint does not merge changes with existing customizations. Reading a document before replacing it does not prevent another edit between requests.
The authenticated user must be an organization owner or a team maintainer. For an organization team managed by an enterprise team or SCIM-backed identity provider group, the authenticated user must be an organization owner. Token permissions do not grant access to teams the authenticated user cannot administer.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.
Fine-grained personal access tokens and GitHub App user access tokens need the organization's
"Copilot agent settings" permission with write access. GitHub App installation access tokens are not supported.
Enterprise teams are not supported.
Returns 200 with the submitted document after a successful write, including the first write.
Documents that fail validation return 422 with the reason. A concurrent edit can return 409.
“Set Copilot customizations for a team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Copilot agent settings" organization permissions (write)
“”Set Copilot customizations for a team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
org string 必须The organization name. The name is not case sensitive. |
team_slug string 必须The slug of the team name. |
| 名称, 类型, 说明 | |||||
|---|---|---|---|---|---|
pluginAssignments object Plugins assigned to the team, keyed by | |||||
Properties of |
| 名称, 类型, 说明 | ||
|---|---|---|
key object A user-defined key to represent an item in | ||
Properties of |
| 名称, 类型, 说明 |
|---|
state string The assignment state. 值: |
extraKnownMarketplaces object Additional plugin marketplaces available to the team, keyed by marketplace name.
Properties of extraKnownMarketplaces
| 名称, 类型, 说明 |
|---|
key object A user-defined key to represent an item in |
“Set Copilot customizations for a team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
409 | Conflict |
422 | Validation failed, or the endpoint has been spammed. |
500 | Internal Error |
503 | Service unavailable |
“Set Copilot customizations for a team”的代码示例
如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com。
请求示例
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/copilot/customizations \
-d '{"pluginAssignments":{"code-review@acme-marketplace":{"state":"defaultEnabled"}},"extraKnownMarketplaces":{"acme-marketplace":{"source":{"source":"github","repo":"acme/copilot-marketplace"}}}}'Response
Status: 200{
"pluginAssignments": {
"code-review@acme-marketplace": {
"state": "defaultEnabled"
}
},
"extraKnownMarketplaces": {
"acme-marketplace": {
"source": {
"source": "github",
"repo": "acme/copilot-marketplace"
}
}
}
}Delete Copilot customizations for a team
Deletes the GitHub-managed Copilot customization document for an organization team. Enterprise teams are not supported.
Returns 204 with no response body, including when the team has no customization document.
The authenticated user must be an organization owner or a team maintainer. For an organization team managed by an enterprise team or SCIM-backed identity provider group, the authenticated user must be an organization owner. Token permissions do not grant access to teams the authenticated user cannot administer.
OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint.
Fine-grained personal access tokens and GitHub App user access tokens need the organization's
"Copilot agent settings" permission with write access. GitHub App installation access tokens are not supported.
A concurrent edit can return 409.
“Delete Copilot customizations for a team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Copilot agent settings" organization permissions (write)
“”Delete Copilot customizations for a team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
org string 必须The organization name. The name is not case sensitive. |
team_slug string 必须The slug of the team name. |
“Delete Copilot customizations for a team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
204 | No Content |
401 | Requires authentication |
403 | Forbidden |
404 | Resource not found |
409 | Conflict |
422 | Validation failed, or the endpoint has been spammed. |
500 | Internal Error |
503 | Service unavailable |
“Delete Copilot customizations for a team”的代码示例
如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com。
请求示例
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/orgs/ORG/teams/TEAM_SLUG/copilot/customizationsResponse
Status: 204