Конечные точки REST API для соответствия лицензий
Используйте REST API для проверки пакетов в соответствии с политикой соответствия лицензий репозитория.
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.
Детализированные токены доступа для «Get the license compliance policy for an enterprise»
Эта конечная точка работает со следующими точными типами маркеров:
Маркер с точной детализацией должен иметь следующий набор разрешений.:
- "Enterprise license policy" enterprise permissions (read)
Параметры для «Get the license compliance policy for an enterprise»
| Имя., Тип, Description |
|---|
accept string Setting to |
| Имя., Тип, Description |
|---|
enterprise string Обязательное полеThe slug version of the enterprise name. |
policy_id string Обязательное полеThe unique identifier of the policy within the enterprise. Currently, only |
HTTP-коды статуса ответа для «Get the license compliance policy for an enterprise»
| Код состояния | Description |
|---|---|
200 | OK |
404 | Resource not found |
503 | Service unavailable |
Примеры кода для «Get the license compliance policy for an enterprise»
Если вы получаете доступ к GitHub на GHE.com, замените api.github.com на выделенный поддомен вашего предприятия в api.SUBDOMAIN.ghe.com.
Пример запроса
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.
Детализированные токены доступа для «Set the license compliance policy for an enterprise»
Эта конечная точка работает со следующими точными типами маркеров:
Маркер с точной детализацией должен иметь следующий набор разрешений.:
- "Enterprise license policy" enterprise permissions (write)
Параметры для «Set the license compliance policy for an enterprise»
| Имя., Тип, Description |
|---|
accept string Setting to |
| Имя., Тип, Description |
|---|
enterprise string Обязательное полеThe slug version of the enterprise name. |
policy_id string Обязательное полеThe unique identifier of the policy within the enterprise. Currently, only |
| Имя., Тип, Description | |||||||
|---|---|---|---|---|---|---|---|
licenses object Обязательное поле | |||||||
Properties of |
| Имя., Тип, Description | |||
|---|---|---|---|
allowed array of objects Обязательное полеThe licenses allowed by this policy. | |||
Properties of |
| Имя., Тип, Description |
|---|
spdx_id string Обязательное полеThe SPDX identifier of the license. |
added_at string or null Обязательное полеThe time the license was added to the policy. |
packages array of objects Обязательное полеThe package-level exceptions in this policy.
Properties of packages
| Имя., Тип, Description |
|---|
package_manager string Обязательное полеThe package manager the package belongs to. Возможные значения: |
name string Обязательное полеThe name of the package. |
action string Обязательное полеHow the package is treated by the policy. Возможные значения: |
reason string Обязательное полеThe reason the exception was added. |
extra_allowed_spdx_ids array of strings Обязательное полеAdditional SPDX identifiers allowed for this package. |
added_at string or null Обязательное полеThe time the exception was added to the policy. |
HTTP-коды статуса ответа для «Set the license compliance policy for an enterprise»
| Код состояния | 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 |
Примеры кода для «Set the license compliance policy for an enterprise»
Если вы получаете доступ к GitHub на GHE.com, замените api.github.com на выделенный поддомен вашего предприятия в api.SUBDOMAIN.ghe.com.
Пример запроса
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.
Детализированные токены доступа для «Check license compliance for packages»
Эта конечная точка работает со следующими точными типами маркеров:
- Жетоны доступа пользователей приложения GitHub
- Токены доступа к установке приложений GitHub
- Точные личные маркеры доступа
Маркер с точной детализацией должен иметь следующий набор разрешений.:
- "Repository license policy" repository permissions (read)
Параметры для «Check license compliance for packages»
| Имя., Тип, Description |
|---|
accept string Setting to |
| Имя., Тип, Description |
|---|
owner string Обязательное полеThe account owner of the repository. The name is not case sensitive. |
repo string Обязательное полеThe name of the repository without the |
| Имя., Тип, Description |
|---|
purls array of strings Обязательное полеUp to 40 package URLs to check against the license compliance policy. Duplicate package URLs count toward the limit but are checked once. |
HTTP-коды статуса ответа для «Check license compliance for packages»
| Код состояния | 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 |
Примеры кода для «Check license compliance for packages»
Если вы получаете доступ к GitHub на GHE.com, замените api.github.com на выделенный поддомен вашего предприятия в api.SUBDOMAIN.ghe.com.
Примеры запросов
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"
}
}
}