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

Set labels for an issue

Replaces the labels assigned to an issue with the labels in the request. Identify the issue with owner, repo, and issue_number, and provide label names through the supported object or array forms. Send an empty labels array to remove every label from the issue.

  • 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 whose labels should be replaced.

A label-replacement payload supplied as an object or array; the submitted labels replace the issue's existing labels.

labelsarray<string>optional
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](https://docs.github.com/rest/issues/labels#add-labels-to-an-issue)."

5 status codes
200Returns an array of the issue's labels after the existing set has been replaced.
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 the object form, labels must contain at least one item unless you intentionally send an empty array to clear all labels.