Skip to main content

labels

Creates, updates, deletes, gets or lists a labels resource.

Overview

Namelabels
TypeResource
Idgithub.issues.labels

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idinteger (int64)Unique identifier for the label.
namestringThe name of the label. (example: bug)
node_idstring (example: MDU6TGFiZWwyMDgwNDU5NDY=)
colorstring6-character hex code, without the leading #, identifying the color (example: FFFFFF)
defaultbooleanWhether this label comes by default in a new repository.
descriptionstringOptional description of the label, such as its purpose. (example: Something isn't working)
urlstring (uri)URL for the label (example: https://api.github.com/repositories/42/labels/bug)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_labels_on_issueselectowner, repo, issue_numberper_page, pageLists all labels for an issue.
get_labelselectowner, repo, nameGets a label using the given name.
list_labels_for_milestoneselectowner, repo, milestone_numberper_page, pageLists labels for issues in a milestone.
list_labels_for_reposelectowner, repoper_page, pageLists all labels for a repository.
add_labelsinsertowner, repo, issue_numberAdds labels to an issue.
create_labelinsertowner, repo, nameCreates a label for the specified repository with the given name and color. The name and color parameters are required. The color must be a valid hexadecimal color code.
update_labelupdateowner, repo, nameUpdates a label using the given label name.
set_labelsreplaceowner, repo, issue_numberRemoves any previous labels and sets the new labels for an issue.
remove_labeldeleteowner, repo, issue_number, nameRemoves 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.
remove_all_labelsdeleteowner, repo, issue_numberRemoves all labels from an issue.
delete_labeldeleteowner, repo, nameDeletes a label using the given label name.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
issue_numberintegerThe number that identifies the issue.
milestone_numberintegerThe number that identifies the milestone.
namestring
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

SELECT examples

Lists all labels for an issue.

SELECT
id,
name,
node_id,
color,
default,
description,
url
FROM github.issues.labels
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND issue_number = '{{ issue_number }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;

INSERT examples

Adds labels to an issue.

INSERT INTO github.issues.labels (
labels,
owner,
repo,
issue_number
)
SELECT
'{{ labels }}',
'{{ owner }}',
'{{ repo }}',
'{{ issue_number }}'
RETURNING
id,
name,
node_id,
color,
default,
description,
url
;

UPDATE examples

Updates a label using the given label name.

UPDATE github.issues.labels
SET
new_name = '{{ new_name }}',
color = '{{ color }}',
description = '{{ description }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND name = '{{ name }}' --required
RETURNING
id,
name,
node_id,
color,
default,
description,
url;

REPLACE examples

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

REPLACE github.issues.labels
SET
labels = '{{ labels }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND issue_number = '{{ issue_number }}' --required
RETURNING
id,
name,
node_id,
color,
default,
description,
url;

DELETE examples

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 FROM github.issues.labels
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND issue_number = '{{ issue_number }}' --required
AND name = '{{ name }}' --required
;