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

Create a label

Creates 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.

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

2 parameters · 3 body fields
ownerstringrequired
The account owner of the repository. The name is not case sensitive.
repostringrequired
The name of the repository without the `.git` extension. The name is not case sensitive.
namestringrequired
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:](https://github.githubassets.com/images/icons/emoji/unicode/1f353.png ":strawberry:"). For a full list of available emoji and codes, see "[Emoji cheat sheet](https://github.com/ikatyang/emoji-cheat-sheet)."
colorstringoptional
The [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`.
descriptionstringoptional
A short description of the label. Must be 100 characters or fewer.

3 status codes
201Response
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.
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 404 is returned: Resource not found. A 422 is returned: Validation failed, or the endpoint has been spammed.