endpoints de API REST para la conformidad de licencias
Use la API REST para comprobar los paquetes según la política de cumplimiento de licencias de un repositorio.
Get the license compliance policy for an enterprise
Gets the license compliance policy for an enterprise.
Currently, only the policy with the ID default is supported.
The authenticated user must be an enterprise owner, or have the "View enterprise license policy" or "Edit enterprise license policy" fine-grained permission on the enterprise.
Tokens de acceso granulares para "Get the license compliance policy for an enterprise"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Enterprise license policy" enterprise permissions (read)
Parámetros para "Get the license compliance policy for an enterprise"
| Nombre, Tipo, Descripción |
|---|
accept string Setting to |
| Nombre, Tipo, Descripción |
|---|
enterprise string ObligatorioThe slug version of the enterprise name. |
policy_id string ObligatorioThe unique identifier of the policy within the enterprise. Currently, only |
Códigos de estado de respuesta HTTP para "Get the license compliance policy for an enterprise"
| código de estado | Descripción |
|---|---|
200 | OK |
404 | Resource not found |
503 | Service unavailable |
Ejemplos de código para "Get the license compliance policy for an enterprise"
Si accede a GitHub en GHE.com, reemplace api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.
Ejemplo de solicitud
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/enterprises/ENTERPRISE/license-compliance/policies/POLICY_IDResponse
Status: 200{
"created_at": "2026-09-22T12:00:00Z",
"licenses": {
"allowed": [
{
"spdx_id": "MIT",
"added_at": "2026-09-22T12:00:00Z"
}
]
},
"packages": [
{
"package_manager": "npm",
"name": "example-package",
"action": "allowed",
"reason": "Approved exception.",
"extra_allowed_spdx_ids": [
"MIT"
],
"added_at": "2026-09-22T12:00:00Z"
}
]
}Set the license compliance policy for an enterprise
Sets the license compliance policy for an enterprise.
Currently, only the policy with the ID default is supported.
The authenticated user must be an enterprise owner, or have the "Edit enterprise license policy" fine-grained permission on the enterprise.
Tokens de acceso granulares para "Set the license compliance policy for an enterprise"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Enterprise license policy" enterprise permissions (write)
Parámetros para "Set the license compliance policy for an enterprise"
| Nombre, Tipo, Descripción |
|---|
accept string Setting to |
| Nombre, Tipo, Descripción |
|---|
enterprise string ObligatorioThe slug version of the enterprise name. |
policy_id string ObligatorioThe unique identifier of the policy within the enterprise. Currently, only |
| Nombre, Tipo, Descripción | |||||||
|---|---|---|---|---|---|---|---|
licenses object Obligatorio | |||||||
Properties of |
| Nombre, Tipo, Descripción | |||
|---|---|---|---|
allowed array of objects ObligatorioThe licenses allowed by this policy. | |||
Properties of |
| Nombre, Tipo, Descripción |
|---|
spdx_id string ObligatorioThe SPDX identifier of the license. |
added_at string or null ObligatorioThe time the license was added to the policy. |
packages array of objects ObligatorioThe package-level exceptions in this policy.
Properties of packages
| Nombre, Tipo, Descripción |
|---|
package_manager string ObligatorioThe package manager the package belongs to. Puede ser uno de los siguientes: |
name string ObligatorioThe name of the package. |
action string ObligatorioHow the package is treated by the policy. Puede ser uno de los siguientes: |
reason string ObligatorioThe reason the exception was added. |
extra_allowed_spdx_ids array of strings ObligatorioAdditional SPDX identifiers allowed for this package. |
added_at string or null ObligatorioThe time the exception was added to the policy. |
Códigos de estado de respuesta HTTP para "Set the license compliance policy for an enterprise"
| código de estado | Descripción |
|---|---|
204 | A header with no content is returned. |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
503 | Service unavailable |
Ejemplos de código para "Set the license compliance policy for an enterprise"
Si accede a GitHub en GHE.com, reemplace api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.
Ejemplo de solicitud
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/enterprises/ENTERPRISE/license-compliance/policies/POLICY_ID \
-d '{"licenses":{"allowed":[{"spdx_id":"MIT","added_at":"2026-09-22T12:00:00Z"}]},"packages":[{"package_manager":"npm","name":"example-package","action":"allowed","reason":"Approved exception.","extra_allowed_spdx_ids":["MIT"],"added_at":"2026-09-22T12:00:00Z"}]}'A header with no content is returned.
Status: 204Check license compliance for packages
Checks whether packages identified by the supplied package URLs (PURLs) are allowed by the repository's license compliance policy.
For requests made on behalf of a user, that user must have write access to the repository or the "View repository license policy" permission.
OAuth apps and classic personal access tokens require the repo scope.
Tokens de acceso granulares para "Check license compliance for packages"
Este punto de conexión funciona con los siguientes tipos de token pormenorizados:
- tokens de acceso de usuario de la aplicación de GitHub
- Token de acceso a la instalación de la aplicación de GitHub
- Tokens de acceso personal específico
El token pormenorizado debe tener el siguiente conjunto de permisos:
- "Repository license policy" repository permissions (read)
Parámetros para "Check license compliance for packages"
| Nombre, Tipo, Descripción |
|---|
accept string Setting to |
| Nombre, Tipo, Descripción |
|---|
owner string ObligatorioThe account owner of the repository. The name is not case sensitive. |
repo string ObligatorioThe name of the repository without the |
| Nombre, Tipo, Descripción |
|---|
purls array of strings ObligatorioUp to 40 package URLs to check against the license compliance policy. Duplicate package URLs count toward the limit but are checked once. |
Códigos de estado de respuesta HTTP para "Check license compliance for packages"
| código de estado | Descripción |
|---|---|
200 | Package license compliance results. |
403 | Forbidden |
404 | License compliance policy not found. |
422 | Validation failed, or the endpoint has been spammed. |
503 | Service unavailable |
Ejemplos de código para "Check license compliance for packages"
Si accede a GitHub en GHE.com, reemplace api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.
Ejemplos de solicitud
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/repos/OWNER/REPO/license-compliance/package-checks \
-d '{"purls":["pkg:npm/lodash@4.17.21"]}'Package license compliance results.
Status: 200{
"purls": {
"pkg:npm/lodash@4.17.21": {
"status": "allowed",
"license": "MIT",
"reason": "allowed_license"
}
}
}