Skip to main content
ドキュメントには� �繁に更新が� えられ、その都度公開されています。本ページの翻訳はま� 未完成な部分があることをご了承く� さい。最新の情� �については、英語のドキュメンテーションをご参照く� さい。本ページの翻訳に問題がある� �合はこちらまでご連絡く� さい。

このバージョンの GitHub Enterprise はこの日付をもって終了となりました: 2022-06-03. 重大なセキュリティの問題に対してであっても、パッチリリースは作成されません。 パフォーマンスの向上、セキュリティの改善、新機能のためには、最新バージョンのGitHub Enterpriseにアップグレードしてく� さい。 アップグレードに関する支援については、GitHub Enterprise supportに連絡してく� さい。

ラベル

Labels APIについて

Labels APIは、リポジトリのラベルの管理と、Issue及びPull Requestのラベルの追� と削除を支援します。 すべてのPull Requestは Issue ですが、すべての Issue がPull Requestというわけではありません。 For this reason, "shared" actions for both features, like managing assignees, labels, and milestones, are provided within Issues API.

List labels for an issue

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

issue_numberinteger必� �

The number that identifies the issue.

クエリパラメータ
名前, 種類, 説明
per_pageinteger

The number of results per page (max 100).

デフォルト: 30

pageinteger

Page number of the results to fetch.

デフォルト: 1

HTTP response status codes

Status code説明
200

OK

410

Gone

コードサンプル

get/repos/{owner}/{repo}/issues/{issue_number}/labels
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels

Response

Status: 200
[ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }, { "id": 208045947, "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement", "name": "enhancement", "description": "New feature or request", "color": "a2eeef", "default": false } ]

Add labels to an issue

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

issue_numberinteger必� �

The number that identifies the issue.

Body parameters
名前, 種類, 説明
labelsarray of strings

The names of the labels to add to the issue's existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a string or an array of labels directly, but GitHub recommends passing an object with the labels key. You can also replace all of the labels for an issue. For more information, see "Set labels for an issue."

HTTP response status codes

Status code説明
200

OK

410

Gone

422

Validation failed

コードサンプル

post/repos/{owner}/{repo}/issues/{issue_number}/labels
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \ -d '{"labels":["bug","enhancement"]}'

Response

Status: 200
[ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }, { "id": 208045947, "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement", "name": "enhancement", "description": "New feature or request", "color": "a2eeef", "default": false } ]

Set labels for an issue

Works with GitHub Apps

Removes any previous labels and sets the new labels for an issue.

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

issue_numberinteger必� �

The number that identifies the issue.

Body parameters
名前, 種類, 説明
labelsarray of strings

The names of the labels to set for the issue. The labels you set replace any existing labels. You can pass an empty array to remove all labels. Alternatively, you can pass a single label as a string or an array of labels directly, but GitHub recommends passing an object with the labels key. You can also add labels to the existing labels for an issue. For more information, see "Add labels to an issue."

HTTP response status codes

Status code説明
200

OK

410

Gone

422

Validation failed

コードサンプル

put/repos/{owner}/{repo}/issues/{issue_number}/labels
curl \ -X PUT \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \ -d '{"labels":["bug","enhancement"]}'

Response

Status: 200
[ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }, { "id": 208045947, "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement", "name": "enhancement", "description": "New feature or request", "color": "a2eeef", "default": false } ]

Remove all labels from an issue

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

issue_numberinteger必� �

The number that identifies the issue.

HTTP response status codes

Status code説明
204

No Content

410

Gone

コードサンプル

delete/repos/{owner}/{repo}/issues/{issue_number}/labels
curl \ -X DELETE \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels

Response

Status: 204

Remove a label from an issue

Works with GitHub Apps

Removes the specified label from the issue, and returns the remaining labels on the issue. This endpoint returns a 404 Not Found status if the label does not exist.

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

issue_numberinteger必� �

The number that identifies the issue.

namestring必� �

HTTP response status codes

Status code説明
200

OK

404

Resource not found

410

Gone

コードサンプル

delete/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}
curl \ -X DELETE \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels/NAME

Response

Status: 200
[ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true } ]

List labels for a repository

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

クエリパラメータ
名前, 種類, 説明
per_pageinteger

The number of results per page (max 100).

デフォルト: 30

pageinteger

Page number of the results to fetch.

デフォルト: 1

HTTP response status codes

Status code説明
200

OK

404

Resource not found

コードサンプル

get/repos/{owner}/{repo}/labels
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels

Response

Status: 200
[ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }, { "id": 208045947, "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement", "name": "enhancement", "description": "New feature or request", "color": "a2eeef", "default": false } ]

Create a label

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

Body parameters
名前, 種類, 説明
namestring必� �

The name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing :strawberry: will render the emoji :strawberry:. For a full list of available emoji and codes, see "Emoji cheat sheet."

colorstring

The hexadecimal color code for the label, without the leading #.

descriptionstring

A short description of the label. Must be 100 characters or fewer.

HTTP response status codes

Status code説明
201

Created

404

Resource not found

422

Validation failed

コードサンプル

post/repos/{owner}/{repo}/labels
curl \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels \ -d '{"name":"bug","description":"Something isn't working","color":"f29513"}'

Response

Status: 201
{ "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }

Get a label

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

namestring必� �

HTTP response status codes

Status code説明
200

OK

404

Resource not found

コードサンプル

get/repos/{owner}/{repo}/labels/{name}
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAME

Response

Status: 200
{ "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }

Update a label

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

namestring必� �
Body parameters
名前, 種類, 説明
new_namestring

The new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing :strawberry: will render the emoji :strawberry:. For a full list of available emoji and codes, see "Emoji cheat sheet."

colorstring

The hexadecimal color code for the label, without the leading #.

descriptionstring

A short description of the label. Must be 100 characters or fewer.

HTTP response status codes

Status code説明
200

OK

コードサンプル

patch/repos/{owner}/{repo}/labels/{name}
curl \ -X PATCH \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAME \ -d '{"new_name":"bug :bug:","description":"Small bug fix required","color":"b01f26"}'

Response

Status: 200
{ "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug%20:bug:", "name": "bug :bug:", "description": "Small bug fix required", "color": "b01f26", "default": true }

Delete a label

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

namestring必� �

HTTP response status codes

Status code説明
204

No Content

コードサンプル

delete/repos/{owner}/{repo}/labels/{name}
curl \ -X DELETE \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/labels/NAME

Response

Status: 204

List labels for issues in a milestone

Works with GitHub Apps

パラメータ

Headers
名前, 種類, 説明
acceptstring

Setting to application/vnd.github.v3+json is recommended.

Path parameters
名前, 種類, 説明
ownerstring必� �

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

repostring必� �

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

milestone_numberinteger必� �

The number that identifies the milestone.

クエリパラメータ
名前, 種類, 説明
per_pageinteger

The number of results per page (max 100).

デフォルト: 30

pageinteger

Page number of the results to fetch.

デフォルト: 1

HTTP response status codes

Status code説明
200

OK

コードサンプル

get/repos/{owner}/{repo}/milestones/{milestone_number}/labels
curl \ -H "Accept: application/vnd.github.v3+json" \ -H "Authorization: token <TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labels

Response

Status: 200
[ { "id": 208045946, "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/bug", "name": "bug", "description": "Something isn't working", "color": "f29513", "default": true }, { "id": 208045947, "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", "url": "https://api.github.com/repos/octocat/Hello-World/labels/enhancement", "name": "enhancement", "description": "New feature or request", "color": "a2eeef", "default": false } ]