Create issue label¶
POST /api/v5/repos/{owner}/{repo}/issues/{number}/labels
Creates labels for a specific issue in the specified repository. By submitting a list of label names, you can add one or more labels to the issue, and returns details of the created labels, including name, color, title, and ID.
Access token support¶
- AtomGit user access token (AtomGit user access tokens)
Anonymous access¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Address path of the namespace that owns the repository (the address path of an organization or an individual) |
repo |
path | string | Yes | Repository path (path) |
number |
path | string | Yes | Issue number |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body is an array of label names, listing the label names to create for the issue.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"type": "string",
"description": "Label name"
},
"description": "List of label names to create"
}
Response parameters¶
The response body is an array of label objects, each corresponding to one label. Each array element is structured as follows:
label object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
color |
string | Yes | No | Label color |
name |
string | Yes | No | Label name |
id |
integer | Yes | No | Label ID |
title |
string | Yes | No | Label title |
type |
null | Yes | Yes | Label type; currently null |
textColor |
string | Yes | No | Label text color |
Error responses¶
400 Parameter error
401 Unauthenticated
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Parameter error (Bad request) |
401 |
Requires authentication (Requires authentication) |
403 |
Forbidden (Forbidden) |
404 |
Resource not found (Not found) |
429 |
Too many requests (Too many requests) |
500 |
Internal server error (Internal server error) |
Request example¶
Parameter notes¶
Replace
<owner>with the address path of the namespace that owns the repository (the address path of an organization or an individual); replace<repo>with the repository path (path); replace<number>with the issue number; replace<token>with your AtomGit user access token.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/labels?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '["bug", "help wanted"]'
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/labels?access_token=<token>",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify(["bug", "help wanted"]),
}
);
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.post(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/labels",
params={"access_token": "<token>"},
headers={
"Content-Type": "application/json",
"Accept": "application/json",
},
json=["bug", "help wanted"],
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
[
{
"color": "#008672",
"name": "help wanted",
"id": 381445,
"title": "help wanted",
"type": null,
"textColor": "#FFFFFF"
}
]
Error codes¶
| Error code | Description |
|---|---|
400 |
Invalid parameters or unparsable request |
401 |
Unauthenticated or invalid credentials (missing or invalid access credential) |
403 |
Forbidden |
404 |
Request path does not exist |
429 |
Too many requests; rate limit triggered |
500 |
Internal server error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc