Create a repository task label¶
POST /api/v5/repos/{owner}/{repo}/labels
This endpoint creates a task label under the specified repository. Submitting a label name and color completes the creation; on success it returns the label's identifier, name, and color information.
Access token support¶
- AtomGit user access tokens
Anonymous access allowed¶
Anonymous access is not allowed for this endpoint.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | The namespace address the repository belongs to (the address path of an enterprise, organization, or individual) |
repo |
path | string | Yes | Repository path |
access_token |
query | string | Yes | User authorization code |
name |
form-data | string | Yes | Label name |
color |
form-data | string | Yes | The label's new color, e.g. #fff |
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | No | Label ID |
name |
string | Yes | No | Label name |
color |
string | Yes | No | Label color |
Error responses¶
401 Unauthenticated
400 Invalid parameters
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Bad request |
401 |
Requires authentication |
404 |
Repository not found |
500 |
Internal server error |
Request example¶
Parameter notes¶
<owner> is the namespace address the repository belongs to (the address path of an enterprise, organization, or individual); <repo> is the repository path; <token> is your AtomGit user access token.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/labels?access_token=<token>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'name=test1&color=%23fff'
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/labels?access_token=<token>",
{
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "application/json",
},
body: new URLSearchParams({
name: "test1",
color: "#fff",
}),
}
);
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>/labels",
params={"access_token": "<token>"},
data={"name": "test1", "color": "#fff"},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
Error codes¶
| Error code | Description |
|---|---|
400 |
Invalid parameters or the request cannot be parsed |
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
404 |
Request path does not exist |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc