Skip to main content
REST API 现已开始进行版本化。 有关详细信息,请参阅“关于 API 版本控制”。

用于企业访问验证的 REST API 终结点

使用 REST API 在 GitHub 企业版中管理企业访问验证配置。

Disable access restrictions for an enterprise

Disable access restriction by proxy header using the network proxy owned by the enterprise.

“Disable access restrictions for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Disable access restrictions for an enterprise 的参数

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

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

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

The slug version of the enterprise name.

“Disable access restrictions for an enterprise”的 HTTP 响应状态代码

状态代码说明
200

OK

400

Forbidden

404

Resource not found

500

Internal Error

“Disable access restrictions for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

post/enterprises/{enterprise}/access-restrictions/disable
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/access-restrictions/disable

Response

Status: 200
{ "message": "Enterprise access restrictions successfully disabled.", "header_name": "sec-GitHub-allowed-enterprise", "header_value": "12345" }

Enable access restrictions for an enterprise

Enable access restriction by proxy header using the network proxy owned by the enterprise.

“Enable access restrictions for an enterprise”的细粒度访问令牌

此终结点不适用于GitHub应用用户访问令牌、GitHub应用安装访问令牌或精细的个人访问令牌。

“”Enable access restrictions for an enterprise 的参数

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

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

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

The slug version of the enterprise name.

“Enable access restrictions for an enterprise”的 HTTP 响应状态代码

状态代码说明
200

OK

400

Forbidden

404

Resource not found

500

Internal Error

“Enable access restrictions for an enterprise”的代码示例

如果你在 GHE.com 上访问 GitHub,请将 api.github.com 替换为企业的专用子域,位于 api.SUBDOMAIN.ghe.com

请求示例

post/enterprises/{enterprise}/access-restrictions/enable
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2026-03-10" \ https://api.github.com/enterprises/ENTERPRISE/access-restrictions/enable

Response

Status: 200
{ "message": "Enterprise access restrictions successfully enabled.", "header_name": "sec-GitHub-allowed-enterprise", "header_value": "12345" }