Skip to main content
REST API 现已经过版本控制。 有关详细信息,请参阅“关于 API 版本控制”。

REST API endpoints for enterprise team organizations

Use the REST API to create and manage organization assignments for enterprise teams in your GitHub enterprise.

About enterprise team organizations

注意

这些终结点目前为 公共预览版,可能会更改。

此 API 文档适用于使用 GitHub Enterprise Cloud 的企业。

如果你的企业使用的是面向非 GHE 的 Copilot Business,请参考此前已向你共享的早期访问文档链接。

这些终结点仅对拥有经典 personal access tokens 且具备 read:enterprisescope 权限(针对 GET API)和 admin:enterprise 权限(针对其他 API)的企业团队中经过身份验证的成员开放。

这些终结点与 fine-grained personal access tokens 或 GitHub Apps 访问令牌不兼容。

GitHub 会从团队 name 生成企业团队的 slug,并添加 ent: 前缀。

Get organization assignments

Get all organizations assigned to an enterprise team

“Get organization assignments”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Get organization assignments”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

enterprise-team string 必须

The slug version of the enterprise team name. You can also substitute this value with the enterprise team id.

查询参数
名称, 类型, 说明
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

默认: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

默认: 1

“Get organization assignments”的 HTTP 响应状态代码

状态代码说明
200

An array of organizations the team is assigned to

“Get organization assignments”的示例代码

请求示例

get/enterprises/{enterprise}/teams/{enterprise-team}/organizations
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/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations

An array of organizations the team is assigned to

Status: 200
{ "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }

Add organization assignments

Assign an enterprise team to multiple organizations.

“Add organization assignments”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Add organization assignments”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

enterprise-team string 必须

The slug version of the enterprise team name. You can also substitute this value with the enterprise team id.

正文参数
名称, 类型, 说明
organization_slugs array of strings 必须

Organization slug to assign the team to.

“Add organization assignments”的 HTTP 响应状态代码

状态代码说明
200

Successfully assigned the enterprise team to organizations.

“Add organization assignments”的示例代码

请求示例

post/enterprises/{enterprise}/teams/{enterprise-team}/organizations/add
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/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/add \ -d '{"organization_slugs":["github"]}'

Successfully assigned the enterprise team to organizations.

Status: 200
[ { "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" } ]

Remove organization assignments

Unassign an enterprise team from multiple organizations.

“Remove organization assignments”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Remove organization assignments”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

enterprise-team string 必须

The slug version of the enterprise team name. You can also substitute this value with the enterprise team id.

正文参数
名称, 类型, 说明
organization_slugs array of strings 必须

Organization slug to unassign the team from.

“Remove organization assignments”的 HTTP 响应状态代码

状态代码说明
204

Successfully unassigned the enterprise team from organizations.

“Remove organization assignments”的示例代码

请求示例

post/enterprises/{enterprise}/teams/{enterprise-team}/organizations/remove
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/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/remove \ -d '{"organization_slugs":["github"]}'

Successfully unassigned the enterprise team from organizations.

Status: 204

Get organization assignment

Check if an enterprise team is assigned to an organization

“Get organization assignment”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Get organization assignment”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

enterprise-team string 必须

The slug version of the enterprise team name. You can also substitute this value with the enterprise team id.

org string 必须

The organization name. The name is not case sensitive.

“Get organization assignment”的 HTTP 响应状态代码

状态代码说明
200

The team is assigned to the organization

404

The team is not assigned to the organization

“Get organization assignment”的示例代码

请求示例

get/enterprises/{enterprise}/teams/{enterprise-team}/organizations/{org}
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/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/ORG

The team is assigned to the organization

Status: 200
{ "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }

Add an organization assignment

Assign an enterprise team to an organization.

“Add an organization assignment”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Add an organization assignment”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

enterprise-team string 必须

The slug version of the enterprise team name. You can also substitute this value with the enterprise team id.

org string 必须

The organization name. The name is not case sensitive.

“Add an organization assignment”的 HTTP 响应状态代码

状态代码说明
201

Successfully assigned the enterprise team to the organization.

“Add an organization assignment”的示例代码

请求示例

put/enterprises/{enterprise}/teams/{enterprise-team}/organizations/{org}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/ORG

Successfully assigned the enterprise team to the organization.

Status: 201
{ "login": "github", "id": 1, "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=", "url": "https://api.github.com/orgs/github", "repos_url": "https://api.github.com/orgs/github/repos", "events_url": "https://api.github.com/orgs/github/events", "hooks_url": "https://api.github.com/orgs/github/hooks", "issues_url": "https://api.github.com/orgs/github/issues", "members_url": "https://api.github.com/orgs/github/members{/member}", "public_members_url": "https://api.github.com/orgs/github/public_members{/member}", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "description": "A great organization" }

Delete an organization assignment

Unassign an enterprise team from an organization.

“Delete an organization assignment”的细粒度访问令牌

此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。

“Delete an organization assignment”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
enterprise string 必须

The slug version of the enterprise name.

enterprise-team string 必须

The slug version of the enterprise team name. You can also substitute this value with the enterprise team id.

org string 必须

The organization name. The name is not case sensitive.

“Delete an organization assignment”的 HTTP 响应状态代码

状态代码说明
204

Successfully unassigned the enterprise team from the organization.

“Delete an organization assignment”的示例代码

请求示例

delete/enterprises/{enterprise}/teams/{enterprise-team}/organizations/{org}
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/enterprises/ENTERPRISE/teams/ENTERPRISE-TEAM/organizations/ORG

Successfully unassigned the enterprise team from the organization.

Status: 204