Endpoints d’API REST pour la conformité des licences logicielles
Utilisez l’API REST pour vérifier la conformité des packages à la stratégie de conformité des licences d’un référentiel.
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.
Jetons d'accès granulaires pour «Get the license compliance policy for an enterprise»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
- jetons d’accès utilisateur de l’application GitHub
- jetons d’accès d’installation de l’application GitHub
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Enterprise license policy" enterprise permissions (read)
Paramètres pour «Get the license compliance policy for an enterprise »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
enterprise string RequisThe slug version of the enterprise name. |
policy_id string RequisThe unique identifier of the policy within the enterprise. Currently, only |
Codes d’état de réponse HTTP pour «Get the license compliance policy for an enterprise »
| Code de statut | Description |
|---|---|
200 | OK |
404 | Resource not found |
503 | Service unavailable |
Exemples de code pour «Get the license compliance policy for an enterprise »
Si vous accédez à GitHub à GHE.com, remplacez api.github.com par le sous-domaine dédié de votre entreprise à api.SUBDOMAIN.ghe.com.
Exemple de requête
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.
Jetons d'accès granulaires pour «Set the license compliance policy for an enterprise»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
- jetons d’accès utilisateur de l’application GitHub
- jetons d’accès d’installation de l’application GitHub
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Enterprise license policy" enterprise permissions (write)
Paramètres pour «Set the license compliance policy for an enterprise »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
enterprise string RequisThe slug version of the enterprise name. |
policy_id string RequisThe unique identifier of the policy within the enterprise. Currently, only |
| Nom, Type, Description | |||||||
|---|---|---|---|---|---|---|---|
licenses object Requis | |||||||
Properties of |
| Nom, Type, Description | |||
|---|---|---|---|
allowed array of objects RequisThe licenses allowed by this policy. | |||
Properties of |
| Nom, Type, Description |
|---|
spdx_id string RequisThe SPDX identifier of the license. |
added_at string or null RequisThe time the license was added to the policy. |
packages array of objects RequisThe package-level exceptions in this policy.
Properties of packages
| Nom, Type, Description |
|---|
package_manager string RequisThe package manager the package belongs to. Peut être l'un des: |
name string RequisThe name of the package. |
action string RequisHow the package is treated by the policy. Peut être l'un des: |
reason string RequisThe reason the exception was added. |
extra_allowed_spdx_ids array of strings RequisAdditional SPDX identifiers allowed for this package. |
added_at string or null RequisThe time the exception was added to the policy. |
Codes d’état de réponse HTTP pour «Set the license compliance policy for an enterprise »
| Code de statut | Description |
|---|---|
204 | A header with no content is returned. |
404 | Resource not found |
422 | Validation failed, or the endpoint has been spammed. |
503 | Service unavailable |
Exemples de code pour «Set the license compliance policy for an enterprise »
Si vous accédez à GitHub à GHE.com, remplacez api.github.com par le sous-domaine dédié de votre entreprise à api.SUBDOMAIN.ghe.com.
Exemple de requête
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.
Jetons d'accès granulaires pour «Check license compliance for packages»
Ce point de terminaison fonctionne avec les types de tokens à granularité fine suivants:
- jetons d’accès utilisateur de l’application GitHub
- jetons d’accès d’installation de l’application GitHub
- Tokens d’accès personnel à granularité fine
Le token à granularité fine doit disposer de l’ensemble d’autorisations suivant:
- "Repository license policy" repository permissions (read)
Paramètres pour «Check license compliance for packages »
| Nom, Type, Description |
|---|
accept string Setting to |
| Nom, Type, Description |
|---|
owner string RequisThe account owner of the repository. The name is not case sensitive. |
repo string RequisThe name of the repository without the |
| Nom, Type, Description |
|---|
purls array of strings RequisUp to 40 package URLs to check against the license compliance policy. Duplicate package URLs count toward the limit but are checked once. |
Codes d’état de réponse HTTP pour «Check license compliance for packages »
| Code de statut | Description |
|---|---|
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 |
Exemples de code pour «Check license compliance for packages »
Si vous accédez à GitHub à GHE.com, remplacez api.github.com par le sous-domaine dédié de votre entreprise à api.SUBDOMAIN.ghe.com.
Exemples de requête
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"
}
}
}