Skip to main content
O controle de versão da API REST já foi feito. Para obter mais informações, confira "Sobre o controle de versão da API".

Pontos de extremidade da API REST para rótulos

Use a API REST para gerenciar rótulos de repositórios, problemas e solicitações de pull.

Sobre etiquetas

Use a API REST para gerenciar rótulos de um repositório e adicionar ou remover rótulos de problemas e solicitações de pull. Cada pull request é um problema, mas nem todos os problemas são um pull request. Por esse motivo, as ações "compartilhadas" para ambos os recursos, como gerenciamento de destinatários, rótulos e marcos, são fornecidas nos pontos de extremidade de Problemas.

List labels for an issue

Lists all labels for an issue.

Tokens de acesso refinados para "List labels for an issue"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:read
  • pull_requests:read

Esse ponto de extremidade pode ser usado sem autenticação ou as permissões acima mencionadas se apenas recursos públicos forem solicitados.

Parâmetros para "List labels for an issue"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

issue_number integer Obrigatório

The number that identifies the issue.

Parâmetros de consulta
Nome, Tipo, Descrição
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Padrão: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Padrão: 1

Códigos de status de resposta HTTP para "List labels for an issue"

Código de statusDescrição
200

OK

301

Moved permanently

404

Resource not found

410

Gone

Exemplos de código para "List labels for an issue"

Exemplo de solicitação

get/repos/{owner}/{repo}/issues/{issue_number}/labels
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels

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 } ]

Add labels to an issue

Adds labels to an issue. If you provide an empty array of labels, all labels are removed from the issue.

Tokens de acesso refinados para "Add labels to an issue"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Add labels to an issue"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

issue_number integer Obrigatório

The number that identifies the issue.

Parâmetros do corpo
Nome, Tipo, Descrição
labels array of strings

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 string or an array of labels directly, but GitHub recommends passing an object with the labels key. You can also replace all of the labels for an issue. For more information, see "Set labels for an issue."

Códigos de status de resposta HTTP para "Add labels to an issue"

Código de statusDescrição
200

OK

301

Moved permanently

404

Resource not found

410

Gone

422

Validation failed, or the endpoint has been spammed.

Exemplos de código para "Add labels to an issue"

Exemplo de solicitação

post/repos/{owner}/{repo}/issues/{issue_number}/labels
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \ -d '{"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 } ]

Set labels for an issue

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

Tokens de acesso refinados para "Set labels for an issue"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Set labels for an issue"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

issue_number integer Obrigatório

The number that identifies the issue.

Parâmetros do corpo
Nome, Tipo, Descrição
labels array of strings

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

Códigos de status de resposta HTTP para "Set labels for an issue"

Código de statusDescrição
200

OK

301

Moved permanently

404

Resource not found

410

Gone

422

Validation failed, or the endpoint has been spammed.

Exemplos de código para "Set labels for an issue"

Exemplo de solicitação

put/repos/{owner}/{repo}/issues/{issue_number}/labels
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels \ -d '{"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 } ]

Remove all labels from an issue

Removes all labels from an issue.

Tokens de acesso refinados para "Remove all labels from an issue"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Remove all labels from an issue"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

issue_number integer Obrigatório

The number that identifies the issue.

Códigos de status de resposta HTTP para "Remove all labels from an issue"

Código de statusDescrição
204

No Content

301

Moved permanently

404

Resource not found

410

Gone

Exemplos de código para "Remove all labels from an issue"

Exemplo de solicitação

delete/repos/{owner}/{repo}/issues/{issue_number}/labels
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels

Response

Status: 204

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.

Tokens de acesso refinados para "Remove a label from an issue"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Remove a label from an issue"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

issue_number integer Obrigatório

The number that identifies the issue.

name string Obrigatório

Códigos de status de resposta HTTP para "Remove a label from an issue"

Código de statusDescrição
200

OK

301

Moved permanently

404

Resource not found

410

Gone

Exemplos de código para "Remove a label from an issue"

Exemplo de solicitação

delete/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/issues/ISSUE_NUMBER/labels/NAME

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 } ]

List labels for a repository

Lists all labels for a repository.

Tokens de acesso refinados para "List labels for a repository"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:read
  • pull_requests:read

Esse ponto de extremidade pode ser usado sem autenticação ou as permissões acima mencionadas se apenas recursos públicos forem solicitados.

Parâmetros para "List labels for a repository"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

Parâmetros de consulta
Nome, Tipo, Descrição
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Padrão: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Padrão: 1

Códigos de status de resposta HTTP para "List labels for a repository"

Código de statusDescrição
200

OK

404

Resource not found

Exemplos de código para "List labels for a repository"

Exemplo de solicitação

get/repos/{owner}/{repo}/labels
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/labels

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 } ]

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.

Tokens de acesso refinados para "Create a label"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Create a label"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

Parâmetros do corpo
Nome, Tipo, Descrição
name string Obrigatório

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:. For a full list of available emoji and codes, see "Emoji cheat sheet."

color string

The hexadecimal color code for the label, without the leading #.

description string

A short description of the label. Must be 100 characters or fewer.

Códigos de status de resposta HTTP para "Create a label"

Código de statusDescrição
201

Created

404

Resource not found

422

Validation failed, or the endpoint has been spammed.

Exemplos de código para "Create a label"

Exemplo de solicitação

post/repos/{owner}/{repo}/labels
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/labels \ -d '{"name":"bug","description":"Something isn'\''t working","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 }

Get a label

Gets a label using the given name.

Tokens de acesso refinados para "Get a label"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:read
  • pull_requests:read

Esse ponto de extremidade pode ser usado sem autenticação ou as permissões acima mencionadas se apenas recursos públicos forem solicitados.

Parâmetros para "Get a label"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

name string Obrigatório

Códigos de status de resposta HTTP para "Get a label"

Código de statusDescrição
200

OK

404

Resource not found

Exemplos de código para "Get a label"

Exemplo de solicitação

get/repos/{owner}/{repo}/labels/{name}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/labels/NAME

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 }

Update a label

Updates a label using the given label name.

Tokens de acesso refinados para "Update a label"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Update a label"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

name string Obrigatório
Parâmetros do corpo
Nome, Tipo, Descrição
new_name string

The new 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:. For a full list of available emoji and codes, see "Emoji cheat sheet."

color string

The hexadecimal color code for the label, without the leading #.

description string

A short description of the label. Must be 100 characters or fewer.

Códigos de status de resposta HTTP para "Update a label"

Código de statusDescrição
200

OK

Exemplos de código para "Update a label"

Exemplo de solicitação

patch/repos/{owner}/{repo}/labels/{name}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/labels/NAME \ -d '{"new_name":"bug :bug:","description":"Small bug fix required","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 }

Delete a label

Deletes a label using the given label name.

Tokens de acesso refinados para "Delete a label"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:write
  • pull_requests:write

Parâmetros para "Delete a label"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

name string Obrigatório

Códigos de status de resposta HTTP para "Delete a label"

Código de statusDescrição
204

No Content

Exemplos de código para "Delete a label"

Exemplo de solicitação

delete/repos/{owner}/{repo}/labels/{name}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/labels/NAME

Response

Status: 204

List labels for issues in a milestone

Lists labels for issues in a milestone.

Tokens de acesso refinados para "List labels for issues in a milestone"

Esse ponto de extremidade funciona com os seguintes tipos de token:

O token deve ter pelo menos um dos seguintes conjuntos de permissões:

  • issues:read
  • pull_requests:read

Esse ponto de extremidade pode ser usado sem autenticação ou as permissões acima mencionadas se apenas recursos públicos forem solicitados.

Parâmetros para "List labels for issues in a milestone"

Cabeçalhos
Nome, Tipo, Descrição
accept string

Setting to application/vnd.github+json is recommended.

Parâmetros de caminho
Nome, Tipo, Descrição
owner string Obrigatório

The account owner of the repository. The name is not case sensitive.

repo string Obrigatório

The name of the repository without the .git extension. The name is not case sensitive.

milestone_number integer Obrigatório

The number that identifies the milestone.

Parâmetros de consulta
Nome, Tipo, Descrição
per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Padrão: 30

page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Padrão: 1

Códigos de status de resposta HTTP para "List labels for issues in a milestone"

Código de statusDescrição
200

OK

Exemplos de código para "List labels for issues in a milestone"

Exemplo de solicitação

get/repos/{owner}/{repo}/milestones/{milestone_number}/labels
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/milestones/MILESTONE_NUMBER/labels

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 } ]