创建企业标签¶
POST /api/v8/enterprises/{enterprise_id}/label
用户调用此接口,在指定企业下创建一个标签。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口不允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
enterprise_id |
path | integer | 是 | 企业 id |
access_token |
query | string | 是 | 用户授权码 |
Request Body:
请求体必须为 application/json,字段约束如下:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"name": {
"description": "待创建的标签名称",
"type": "string",
"minLength": 1
},
"color": {
"description": "标签的颜色,以6位16进制表示,前面带有'#'号(例如 #ff0000)",
"type": "string"
},
"description": {
"description": "待创建的标签的描述",
"type": "string"
},
"priority": {
"description": "标签的优先级",
"type": "integer",
"minimum": 0,
"maximum": 30
},
"expires_at": {
"description": "标签的过期日期",
"type": "string"
}
},
"required": ["name"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
id |
integer | 是 | 否 | 标签 id |
name |
string | 是 | 否 | 标签名称 |
color |
string | 是 | 是 | 标签颜色 |
description |
string | 是 | 是 | 标签描述 |
repository_id |
integer | 否 | 是 | 仓库 id(创建成功后不返回该字段值) |
url |
string | 否 | 是 | 标签 url(创建成功后不返回该字段值) |
created_at |
string | 否 | 是 | 创建时间(创建成功后不返回该字段值) |
updated_at |
string | 否 | 是 | 更新时间(创建成功后不返回该字段值) |
失败响应¶
400 参数错误
{
"error_code": 400,
"error_code_name": "BAD_REQUEST",
"error_message": "create enterprise label, name is required"
}
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad Request) |
401 |
未认证(Unauthorized) |
403 |
禁止访问(Forbidden) |
429 |
请求过于频繁(Too Many Requests) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
<enterprise_id>替换为企业的 id;<token>替换为你的 AtomGit 用户访问令牌。
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": "缺陷标签",
"priority": 10,
"expires_at": "2026-12-31"
}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
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: "缺陷标签",
priority: 10,
expires_at: "2026-12-31",
}),
});
if (!response.ok) {
throw new Error(`请求失败: ${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": "缺陷标签",
"priority": 10,
"expires_at": "2026-12-31",
},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效 |
403 |
无权限访问该资源 |
404 |
请求路径不存在 |
405 |
请求方法不支持 |
429 |
请求过于频繁,触发限流 |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc