Skip to main content
Skip to content

REST API endpoints for license compliance

Use the REST API to check packages against a repository's license compliance policy.

Check 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 application/vnd.github+json is recommended.

パスパラメーター
名前, タイプ, 説明
owner string 必須

The account owner of the repository. The name is not case sensitive.

repo string 必須

The name of the repository without the .git extension. The name is not case sensitive.

ボディパラメータ
名前, タイプ, 説明
purls array of strings 必須

Package URLs to check against the license compliance policy. Duplicate package URLs 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" のコード サンプル

GHE.com でGitHubにアクセスする場合は、api.github.com を、api.SUBDOMAIN.ghe.com にある企業の専用サブドメインに置き換えます。

リクエスト例

post/repos/{owner}/{repo}/license-compliance/package-checks
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" } } }