Create an enterprise label¶
POST /api/v8/enterprises/{enterprise_id}/label
Call this endpoint to create a label in the specified enterprise.
Supported access tokens¶
- AtomGit user access tokens
Anonymous access allowed¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
enterprise_id |
path | integer | Yes | Enterprise ID |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body must be application/json, with the following field constraints:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "Name of the label to create",
"type": "string",
"minLength": 1
},
"color": {
"description": "Label color as a 6-digit hexadecimal value prefixed with '#' (for example #ff0000)",
"type": "string"
},
"description": {
"description": "Description of the label to create",
"type": "string"
},
"priority": {
"description": "Label priority",
"type": "integer",
"minimum": 0,
"maximum": 30
},
"expires_at": {
"description": "Label expiration date",
"type": "string"
}
},
"required": ["name"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | No | Label ID |
name |
string | Yes | No | Label name |
color |
string | Yes | Yes | Label color |
description |
string | Yes | Yes | Label description |
repository_id |
integer | No | Yes | Repository ID (not returned after a successful create) |
url |
string | No | Yes | Label URL (not returned after a successful create) |
created_at |
string | No | Yes | Creation time (not returned after a successful create) |
updated_at |
string | No | Yes | Update time (not returned after a successful create) |
Error response¶
400 Invalid parameters
{
"error_code": 400,
"error_code_name": "BAD_REQUEST",
"error_message": "create enterprise label, name is required"
}
401 Unauthenticated
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Invalid parameters (Bad Request) |
401 |
Unauthenticated (Unauthorized) |
403 |
Access forbidden (Forbidden) |
429 |
Too many requests (Too Many Requests) |
500 |
Internal system error (Internal Server Error) |
Request example¶
Parameter notes¶
- Replace
<enterprise_id>with the enterprise ID; - replace
<token>with your AtomGit user access token.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"name": "bug",
"color": "#f6366c",
"description": "Defect label",
"priority": 10,
"expires_at": "2026-12-31"
}'
JavaScript¶
// Native fetch (Node.js 18+ / browsers)
const response = await fetch("https://api.atomgit.com/api/v8/enterprises/<enterprise_id>/label?access_token=<token>", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
name: "bug",
color: "#f6366c",
description: "Defect label",
priority: 10,
expires_at: "2026-12-31",
}),
});
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/v8/enterprises/<enterprise_id>/label",
params={"access_token": "<token>"},
json={
"name": "bug",
"color": "#f6366c",
"description": "Defect label",
"priority": 10,
"expires_at": "2026-12-31",
},
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 |
403 |
No permission to access this resource |
404 |
Request path does not exist |
405 |
Request method not supported |
429 |
Too many requests; rate limit triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc