Skip to main content

Enterprise Server 3.21 actualmente está disponible como versión candidata para lanzamiento.

Ahora la API REST está versionada. Para obtener más información, consulta "Acerca del control de versiones de la API".

Puntos de conexión de API de REST para características de seguridad empresarial para código

Usa la API de REST para administrar el uso de características de seguridad para tu empresa.

Nota:

Estos puntos de conexión solo admiten la autenticación mediante personal access token (classic). Para más información, consulta Administración de tokens de acceso personal.

Get code security and analysis features for an enterprise

Warning

Closing down notice: The ability to fetch code security and analysis settings for an enterprise is closing down. Please use code security configurations instead. For more information, see the changelog.

Gets code security and analysis settings for the specified enterprise.

The authenticated user must be an administrator of the enterprise in order to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the read:enterprise scope to use this endpoint.

Fine-grained access tokens for "Get code security and analysis features for an enterprise"

This endpoint does not work with GitHub App user access tokens, GitHub App installation access tokens, or fine-grained personal access tokens.

Parámetros para "Get code security and analysis features for an enterprise"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

HTTP response status codes for "Get code security and analysis features for an enterprise"

Status codeDescripción
200

OK

404

Resource not found

Code samples for "Get code security and analysis features for an enterprise"

Request example

get/enterprises/{enterprise}/code_security_and_analysis
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/code_security_and_analysis

Response

Status: 200
{ "advanced_security_enabled_for_new_repositories": true, "dependabot_alerts_enabled_for_new_repositories": true, "secret_scanning_enabled_for_new_repositories": true, "secret_scanning_push_protection_enabled_for_new_repositories": true, "secret_scanning_push_protection_custom_link": "https://github.com/test-org/test-repo/blob/main/README.md", "secret_scanning_non_provider_patterns_enabled_for_new_repositories": true }

Update code security and analysis features for an enterprise

Warning

Closing down notice: The ability to update code security and analysis settings for an enterprise is closing down. Please use code security configurations instead. For more information, see the changelog.

Updates the settings for advanced security, Dependabot alerts, secret scanning, and push protection for new repositories in an enterprise.

The authenticated user must be an administrator of the enterprise to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the admin:enterprise scope to use this endpoint.

Fine-grained access tokens for "Update code security and analysis features for an enterprise"

This endpoint does not work with GitHub App user access tokens, GitHub App installation access tokens, or fine-grained personal access tokens.

Parámetros para "Update code security and analysis features for an enterprise"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

Parámetros del cuerpo
Nombre, Tipo, Descripción
advanced_security_enabled_for_new_repositories boolean

Whether GitHub Advanced Security is automatically enabled for new repositories. For more information, see "About GitHub Advanced Security."

advanced_security_enabled_new_user_namespace_repos boolean

Whether GitHub Advanced Security is automatically enabled for new user namespace repositories. For more information, see "About GitHub Advanced Security."

dependabot_alerts_enabled_for_new_repositories boolean

Whether Dependabot alerts are automatically enabled for new repositories. For more information, see "About Dependabot alerts."

secret_scanning_enabled_for_new_repositories boolean

Whether secret scanning is automatically enabled for new repositories. For more information, see "About secret scanning."

secret_scanning_push_protection_enabled_for_new_repositories boolean

Whether secret scanning push protection is automatically enabled for new repositories. For more information, see "Protecting pushes with secret scanning."

secret_scanning_push_protection_custom_link string or null

The URL that will be displayed to contributors who are blocked from pushing a secret. For more information, see "Protecting pushes with secret scanning." To disable this functionality, set this field to null.

secret_scanning_non_provider_patterns_enabled_for_new_repositories boolean or null

Whether secret scanning of non-provider patterns is enabled for new repositories under this enterprise.

HTTP response status codes for "Update code security and analysis features for an enterprise"

Status codeDescripción
204

Action started

404

Resource not found

422

The action could not be taken due to an in progress enablement, or a policy is preventing enablement

Code samples for "Update code security and analysis features for an enterprise"

Request example

patch/enterprises/{enterprise}/code_security_and_analysis
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/code_security_and_analysis \ -d '{"advanced_security_enabled_for_new_repositories":true,"advanced_security_enabled_new_user_namespace_repos":true,"dependabot_alerts_enabled_for_new_repositories":true,"secret_scanning_enabled_for_new_repositories":true,"secret_scanning_push_protection_enabled_for_new_repositories":true,"secret_scanning_push_protection_custom_link":"https://github.com/test-org/test-repo/blob/main/README.md","secret_scanning_non_provider_patterns_enabled_for_new_repositories":true}'

Action started

Status: 204

Enable or disable a security feature

Warning

Closing down notice: The ability to enable or disable a security feature for an enterprise is closing down. Please use code security configurations instead. For more information, see the changelog.

Enables or disables the specified security feature for all repositories in an enterprise.

The authenticated user must be an administrator of the enterprise to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the admin:enterprise scope to use this endpoint.

Fine-grained access tokens for "Enable or disable a security feature"

This endpoint does not work with GitHub App user access tokens, GitHub App installation access tokens, or fine-grained personal access tokens.

Parámetros para "Enable or disable a security feature"

Encabezados
Nombre, Tipo, Descripción
accept string

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

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

security_product string Obligatorio

The security feature to enable or disable.

Puede ser uno de los siguientes: advanced_security, advanced_security_user_namespace, dependabot_alerts, secret_scanning, secret_scanning_push_protection, secret_scanning_non_provider_patterns

enablement string Obligatorio

The action to take.

enable_all means to enable the specified security feature for all repositories in the enterprise. disable_all means to disable the specified security feature for all repositories in the enterprise.

Puede ser uno de los siguientes: enable_all, disable_all

HTTP response status codes for "Enable or disable a security feature"

Status codeDescripción
204

Action started

404

Resource not found

422

The action could not be taken due to an in progress enablement, or a policy is preventing enablement

Code samples for "Enable or disable a security feature"

Request example

post/enterprises/{enterprise}/{security_product}/{enablement}
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/SECURITY_PRODUCT/ENABLEMENT

Action started

Status: 204