适用于企业团队的 REST API 终结点
使用 REST API 在 GitHub 企业版中创建和管理企业团队。
关于企业团队
这些端点仅适用于企业团队所属企业中已通过身份验证的成员;对于 GET API,需要具有经典 personal access tokens 以及 read:enterprisescope,对于其他 API,则需要具有 admin:enterprise。
这些终结点与 fine-grained personal access tokens 或GitHub应用访问令牌不兼容。
GitHub根据团队name生成企业团队的slug,并添加ent:前缀。
List enterprise teams
List all teams in the enterprise for the authenticated user
“List enterprise teams”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (read)
“”List enterprise teams 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
| 名称, 类型, 说明 |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." 默认: |
“List enterprise teams”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
403 | Forbidden |
“List enterprise teams”的代码示例
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teamsResponse
Status: 200[
{
"id": 1,
"name": "Justice League",
"description": "A great team.",
"slug": "justice-league",
"url": "https://HOSTNAME/enterprises/dc/teams/justice-league",
"group_id": "62ab9291-fae2-468e-974b-7e45096d5021",
"html_url": "https://github.com/enterprises/dc/teams/justice-league",
"members_url": "https://HOSTNAME/enterprises/dc/teams/justice-league/members{/member}",
"created_at": "2019-01-26T19:01:12Z",
"updated_at": "2019-01-26T19:14:43Z"
}
]Create an enterprise team
To create an enterprise team, the authenticated user must be an owner of the enterprise.
“Create an enterprise team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“”Create an enterprise team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
| 名称, 类型, 说明 |
|---|
name string 必须The name of the team. |
description string or null A description of the team. |
sync_to_organizations string Retired: this field is no longer supported. Whether the enterprise team should be reflected in each organization. This value cannot be set. 默认: 可以是以下选项之一: |
organization_selection_type string Specifies which organizations in the enterprise should have access to this team. Can be one of 默认: 可以是以下选项之一: |
group_id string or null The ID of the IdP group to assign team membership with. You can get this value from the REST API endpoints for SCIM. |
notification_setting string The notification setting the team is set to. The options are:
Default: 可以是以下选项之一: |
“Create an enterprise team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
201 | Created |
“Create an enterprise team”的代码示例
请求示例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams \
-d '{"name":"Justice League","description":"A great team.","group_id":"62ab9291-fae2-468e-974b-7e45096d5021"}'Response
Status: 201{
"id": 1,
"name": "Justice League",
"description": "A great team.",
"slug": "justice-league",
"url": "https://HOSTNAME/enterprises/dc/teams/justice-league",
"group_id": "62ab9291-fae2-468e-974b-7e45096d5021",
"html_url": "https://github.com/enterprises/dc/teams/justice-league",
"members_url": "https://HOSTNAME/enterprises/dc/teams/justice-league/members{/member}",
"created_at": "2019-01-26T19:01:12Z",
"updated_at": "2019-01-26T19:14:43Z"
}Get an enterprise team
Gets a team using the team's slug. To create the slug, GitHub replaces special characters in the name string, changes all words to lowercase, and replaces spaces with a - separator and adds the "ent:" prefix. For example, "My TEam Näme" would become ent:my-team-name.
“Get an enterprise team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (read)
“”Get an enterprise team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
team_slug string 必须The slug of the team name. |
“Get an enterprise team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
403 | Forbidden |
“Get an enterprise team”的代码示例
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/TEAM_SLUGResponse
Status: 200{
"id": 1,
"name": "Justice League",
"description": "A great team.",
"slug": "justice-league",
"url": "https://HOSTNAME/enterprises/dc/teams/justice-league",
"group_id": "62ab9291-fae2-468e-974b-7e45096d5021",
"html_url": "https://github.com/enterprises/dc/teams/justice-league",
"members_url": "https://HOSTNAME/enterprises/dc/teams/justice-league/members{/member}",
"created_at": "2019-01-26T19:01:12Z",
"updated_at": "2019-01-26T19:14:43Z"
}Update an enterprise team
To edit a team, the authenticated user must be an enterprise owner.
“Update an enterprise team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“”Update an enterprise team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
team_slug string 必须The slug of the team name. |
| 名称, 类型, 说明 |
|---|
name string or null A new name for the team. |
description string or null A new description for the team. |
sync_to_organizations string Retired: this field is no longer supported. Whether the enterprise team should be reflected in each organization. This value cannot be changed. 默认: 可以是以下选项之一: |
organization_selection_type string Specifies which organizations in the enterprise should have access to this team. Can be one of 默认: 可以是以下选项之一: |
group_id string or null The ID of the IdP group to assign team membership with. The new IdP group will replace the existing one, or replace existing direct members if the team isn't currently linked to an IdP group. |
notification_setting string The notification setting the team is set to. The options are:
可以是以下选项之一: |
“Update an enterprise team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
403 | Forbidden |
“Update an enterprise team”的代码示例
请求示例
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/TEAM_SLUG \
-d '{"name":"Justice League","description":"A great team.","group_id":"62ab9291-fae2-468e-974b-7e45096d5021"}'Response
Status: 200{
"id": 1,
"name": "Justice League",
"description": "A great team.",
"slug": "justice-league",
"url": "https://HOSTNAME/enterprises/dc/teams/justice-league",
"group_id": "62ab9291-fae2-468e-974b-7e45096d5021",
"html_url": "https://github.com/enterprises/dc/teams/justice-league",
"members_url": "https://HOSTNAME/enterprises/dc/teams/justice-league/members{/member}",
"created_at": "2019-01-26T19:01:12Z",
"updated_at": "2019-01-26T19:14:43Z"
}Delete an enterprise team
To delete an enterprise team, the authenticated user must be an enterprise owner.
If you are an enterprise owner, deleting an enterprise team will delete all of its IdP mappings as well.
“Delete an enterprise team”的细粒度访问令牌
此端点支持以下精细令牌类型:
细粒度令牌必须具有以下权限集:
- "Enterprise teams" enterprise permissions (write)
“”Delete an enterprise team 的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
enterprise string 必须The slug version of the enterprise name. |
team_slug string 必须The slug of the team name. |
“Delete an enterprise team”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
204 | No Content |
403 | Forbidden |
“Delete an enterprise team”的代码示例
请求示例
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/teams/TEAM_SLUGResponse
Status: 204