라이선스 준수를 위한 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"에 대한 매개 변수
| 이름, 유형, 설명 |
|---|
accept string Setting to |
| 이름, 유형, 설명 |
|---|
enterprise string 필수The slug version of the enterprise name. |
policy_id string 필수The unique identifier of the policy within the enterprise. Currently, only |
"Get the license compliance policy for an enterprise"에 대한 HTTP 응답 상태 코드
| 상태 코드 | 설명 |
|---|---|
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"에 대한 매개 변수
| 이름, 유형, 설명 |
|---|
accept string Setting to |
| 이름, 유형, 설명 |
|---|
enterprise string 필수The slug version of the enterprise name. |
policy_id string 필수The unique identifier of the policy within the enterprise. Currently, only |
| 이름, 유형, 설명 | |||||||
|---|---|---|---|---|---|---|---|
licenses object 필수 | |||||||
Properties of |
| 이름, 유형, 설명 | |||
|---|---|---|---|
allowed array of objects 필수The licenses allowed by this policy. | |||
Properties of |
| 이름, 유형, 설명 |
|---|
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
| 이름, 유형, 설명 |
|---|
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. |
"Set the license compliance policy for an enterprise"에 대한 HTTP 응답 상태 코드
| 상태 코드 | 설명 |
|---|---|
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"에 대한 세분화된 액세스 토큰
이 엔드포인트는 다음 세분화된 토큰 형식에서 작동합니다.:
세분화된 토큰은 필수 권한 집합을 포함해야 합니다.:
- "Repository license policy" repository permissions (read)
"Check license compliance for packages"에 대한 매개 변수
| 이름, 유형, 설명 |
|---|
accept string Setting to |
| 이름, 유형, 설명 |
|---|
owner string 필수The account owner of the repository. The name is not case sensitive. |
repo string 필수The name of the repository without the |
| 이름, 유형, 설명 |
|---|
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. |
"Check license compliance for packages"에 대한 HTTP 응답 상태 코드
| 상태 코드 | 설명 |
|---|---|
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"
}
}
}