Create a pull request label¶
POST /api/v5/repos/{owner}/{repo}/pulls/{number}/labels
This endpoint creates labels for a specific pull request in the specified repository. You submit an array of label names in the request body, and on success the response returns details of the created labels, including their ID, name, color, and text color.
Supported access tokens¶
- 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 | Namespace address of the repository (the address path of an organization or user) |
repo |
path | string | Yes | Repository path (path) |
number |
path | integer | Yes | Ordinal number of the pull request in this repository |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body is an array of label name strings and must be submitted as application/json.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"description": "Label name",
"type": "string"
}
}
Response parameters¶
| 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, null in the example |
textColor |
string | Yes | No | Label text color |
Error response¶
400 Invalid parameters
401 Unauthenticated
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Requires authentication |
403 |
Forbidden |
404 |
The request path does not exist |
429 |
Too many requests; the rate limit is triggered |
500 |
Internal system error |
Request example¶
Parameter description¶
The placeholders in the example are described below:
Replace
<owner>with the namespace address of the repository (the address path of an organization or user); replace<repo>with the repository path; replace<number>with the pull request ordinal number (which pull request it is); replace<token>with your AtomGit user access token.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/labels?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '["help wanted"]'
JavaScript¶
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/labels?access_token=<token>", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(["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>/pulls/<number>/labels",
params={"access_token": "<token>"},
json=["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 |
|---|---|
401 |
Unauthenticated or invalid credentials (missing or invalid access credentials) |
400 |
Invalid parameters or the request cannot be parsed |
404 |
The request path does not exist |
405 |
Request method not supported |
429 |
Too many requests; the rate limit is triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc