Labels
List labels for an issue
get /repos/{owner}/{repo}/issues/{issue_number}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
issue_number | integer | path | issue_number parameter |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsawait octokit.request('GET /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: 'OWNER',
repo: 'REPO',
issue_number: 'ISSUE_NUMBER'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsResponse
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
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
410 | Gone |
Notes
Add labels to an issue
post /repos/{owner}/{repo}/issues/{issue_number}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
issue_number | integer | path | issue_number parameter |
labels | array of strings | body | 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 |
Code samples
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \
-d '{"labels":["bug","enhancement"]}'await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: 'OWNER',
repo: 'REPO',
issue_number: 'ISSUE_NUMBER',
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
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
410 | Gone |
422 | Validation failed |
Notes
Set labels for an issue
Removes any previous labels and sets the new labels for an issue.
put /repos/{owner}/{repo}/issues/{issue_number}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
issue_number | integer | path | issue_number parameter |
labels | array of strings | body | 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 |
Code samples
Example
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \
-d '{"labels":["bug","enhancement"]}'await octokit.request('PUT /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: 'OWNER',
repo: 'REPO',
issue_number: 'ISSUE_NUMBER',
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
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
410 | Gone |
422 | Validation failed |
Notes
Remove all labels from an issue
delete /repos/{owner}/{repo}/issues/{issue_number}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
issue_number | integer | path | issue_number parameter |
Code samples
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsawait octokit.request('DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: 'OWNER',
repo: 'REPO',
issue_number: 'ISSUE_NUMBER'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/issues/ISSUE_NUMBER/labelsResponse
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
410 | Gone |
Notes
Remove a label from an issue
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.
delete /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
issue_number | integer | path | issue_number parameter |
name | string | path |
Code samples
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels/NAMEawait octokit.request('DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}', {
owner: 'OWNER',
repo: 'REPO',
issue_number: 'ISSUE_NUMBER',
name: 'NAME'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels/NAMEResponse
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
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
404 | Resource not found |
410 | Gone |
Notes
List labels for a repository
get /repos/{owner}/{repo}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/labelsawait octokit.request('GET /repos/{owner}/{repo}/labels', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/labelsResponse
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
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
404 | Resource not found |
Notes
Create a label
post /repos/{owner}/{repo}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
name | string | body | Required. The name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
color | string | body | The hexadecimal color code for the label, without the leading |
description | string | body | A short description of the label. Must be 100 characters or fewer. |
Code samples
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/labels \
-d '{"name":"bug","description":"Something isn't working","color":"f29513"}'await octokit.request('POST /repos/{owner}/{repo}/labels', {
owner: 'OWNER',
repo: 'REPO',
name: 'bug',
description: 'Something isn\'t working',
color: 'f29513'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/labels \
-f name='bug' -f description='Something isn't working' -f 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
}Status codes
| HTTP Status Code | Description |
|---|---|
201 | Created |
404 | Resource not found |
422 | Validation failed |
Notes
Get a label
get /repos/{owner}/{repo}/labels/{name}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
name | string | path |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/labels/NAMEawait octokit.request('GET /repos/{owner}/{repo}/labels/{name}', {
owner: 'OWNER',
repo: 'REPO',
name: 'NAME'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/labels/NAMEResponse
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
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
404 | Resource not found |
Notes
Update a label
patch /repos/{owner}/{repo}/labels/{name}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
name | string | path | |
new_name | string | body | The new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing |
color | string | body | The hexadecimal color code for the label, without the leading |
description | string | body | A short description of the label. Must be 100 characters or fewer. |
Code samples
Example
curl \
-X PATCH \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/labels/NAME \
-d '{"new_name":"bug :bug:","description":"Small bug fix required","color":"b01f26"}'await octokit.request('PATCH /repos/{owner}/{repo}/labels/{name}', {
owner: 'OWNER',
repo: 'REPO',
name: 'NAME',
new_name: 'bug :bug:',
description: 'Small bug fix required',
color: 'b01f26'
})gh api \
--method PATCH \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/labels/NAME \
-f new_name='bug :bug:' -f description='Small bug fix required' -f 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
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
Notes
Delete a label
delete /repos/{owner}/{repo}/labels/{name}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
name | string | path |
Code samples
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/labels/NAMEawait octokit.request('DELETE /repos/{owner}/{repo}/labels/{name}', {
owner: 'OWNER',
repo: 'REPO',
name: 'NAME'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/labels/NAMEResponse
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
Notes
List labels for issues in a milestone
get /repos/{owner}/{repo}/milestones/{milestone_number}/labelsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
milestone_number | integer | path | milestone_number parameter |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labelsawait octokit.request('GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels', {
owner: 'OWNER',
repo: 'REPO',
milestone_number: 'MILESTONE_NUMBER'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labelsResponse
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
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |