Sample - GitHub REST API
POST/repos/{owner}/{repo}/issues/{issue_number}/labels

Add labels to an issue

Adds one or more labels to an issue while preserving its existing labels. Identify the issue with owner, repo, and issue_number, then provide labels as an object, an array of label names, or an array of label objects. Label objects can include rationale, suggest, and confidence to describe or defer the label decision.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

3 parameters · 1 body field
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.
issue_numberintegerrequired
The integer identifying the issue to which labels should be added.

A label-addition payload, supplied as an object with labels, an array of label names, or an array of label objects.

labelsarray<string>optional
The labels to add to the issue's existing labels. You can also pass an `array` of labels directly, but GitHub recommends passing an object with the `labels` key. To replace all of the labels for an issue, use "[Set labels for an issue](https://docs.github.com/rest/issues/labels#set-labels-for-an-issue)."

5 status codes
200Returns an array of the issue's labels after the requested labels have been added.
idintegerrequired
Unique identifier for the label.
node_idstringrequired
urlstringrequired
URL for the label
namestringrequired
The name of the label.
descriptionstringrequired
Optional description of the label, such as its purpose.
colorstringrequired
6-character hex code, without the leading #, identifying the color
defaultbooleanrequired
Whether this label comes by default in a new repository.
archived_atstringrequired
Timestamp indicating when the label was archived, or `null` if it has not been archived.
archived_byobjectrequired
The user who archived the label, or `null` if it has not been archived.
301Returned when the repository or issue URL has moved permanently.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Returned when the specified repository or issue cannot be found.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
410Returned when the endpoint is no longer available.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when the request fails validation or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 404 is returned when the specified repository or issue cannot be found. A 410 is returned when the endpoint is no longer available. A 422 is returned when the payload fails validation or the endpoint has been spammed. When using label objects, name is required, confidence must be low, medium, or high, and labels must contain at least one item when that form is used.