zentao-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese禅道 API v2.0
ZenTao API v2.0
配置
Configuration
优先级从高到低:
| 变量 | 说明 |
|---|---|
| 服务器地址,如 |
| 直接指定 token,跳过登录和缓存(最高优先级),仍需提供服务器地址 |
| 登录账号,有 token 时可选,但提供可更好回答与当前用户相关的问题 |
| 登录密码,有 token 时无需提供 |
首次登录后 、、 写入 ,后续无需重复设置。
ZENTAO_URLZENTAO_TOKENZENTAO_ACCOUNT~/.zentao-token.json若必要变量缺失,提示用户并给出 命令。用户直接提供服务器、账号和密码时直接使用,同时告知尽量设为环境变量。
exportPriority from highest to lowest:
| Variable | Description |
|---|---|
| Server address, e.g. |
| Specify token directly, skip login and cache (highest priority), server address is still required |
| Login account, optional when token is provided, but providing it can better answer questions related to the current user |
| Login password, no need to provide when token is available |
After the first login, , , will be written to , no need to set them repeatedly later.
ZENTAO_URLZENTAO_TOKENZENTAO_ACCOUNT~/.zentao-token.jsonIf necessary variables are missing, prompt the user and provide the command. If the user directly provides the server, account and password, use them directly, and inform the user to set them as environment variables as much as possible.
export认证流程
Authentication Process
所有业务 API 需在 Header 携带 。运行 自动获取:
tokenscripts/get-token.shbash
eval "$(bash scripts/get-token.sh)"All business APIs need to carry in the Header. Run to get it automatically:
tokenscripts/get-token.shbash
eval "$(bash scripts/get-token.sh)"执行后可直接使用 $ZENTAO_URL、$ZENTAO_TOKEN、$ZENTAO_ACCOUNT
After execution, you can directly use $ZENTAO_URL, $ZENTAO_TOKEN, $ZENTAO_ACCOUNT
脚本依赖:`curl`、`node`
后续所有请求 Header 携带:`token: $ZENTAO_TOKEN`
Script dependencies: `curl`, `node`
All subsequent request Headers carry: `token: $ZENTAO_TOKEN`执行 API 调用的步骤
Steps to Execute API Calls
- 运行 获取凭证(自动处理缓存;仍缺失时提示用户)
eval "$(bash scripts/get-token.sh)" - 根据用户意图选择正确的 API 端点(参见 api-reference.md)
- 若为 PUT 编辑操作且用户未提供全部必填字段,先调用对应 GET 详情接口取回当前数据,再将用户指定的字段覆盖进去
- 构造请求(方法、URL、Header、Body)并向用户确认写操作内容
- 执行请求,解析响应
- 以清晰易读的格式向用户展示结果
- Run to obtain credentials (automatically handle cache; prompt the user if still missing)
eval "$(bash scripts/get-token.sh)" - Select the correct API endpoint according to user intent (see api-reference.md)
- If it is a PUT edit operation and the user does not provide all required fields, first call the corresponding GET detail interface to retrieve the current data, then overwrite the fields specified by the user
- Construct the request (method, URL, Header, Body) and confirm the write operation content with the user
- Execute the request and parse the response
- Display the results to the user in a clear and readable format
模块总览
Module Overview
API 基础路径:
$ZENTAO_URL/api.php/v2| 模块 | 资源路径 | 支持操作 |
|---|---|---|
| 项目集 Program | | CRUD + 关联产品/项目列表 |
| 产品 Product | | CRUD + 关联需求/Bug/用例/计划/发布/反馈/工单/测试单/应用 |
| 项目 Project | | CUD + 关联执行/需求/Bug/用例/版本/测试单 |
| 执行 Execution | | CRUD + 关联需求/任务/Bug/用例/版本/测试单 |
| 需求 Story | | CRUD + change/close/activate |
| 业务需求 Epic | | CRUD + change/close/activate |
| 用户需求 Requirement | | CRUD + change/close/activate |
| Bug | | CRUD + resolve/close/activate |
| 任务 Task | | CRUD + start/finish/close/activate |
| 测试用例 Testcase | | CRUD |
| 产品计划 Productplan | | CUD + 按产品查列表 |
| 版本 Build | | CUD + 按项目/执行查列表 |
| 发布 Release | | CUD + 按产品查列表 |
| 测试单 Testtask | | CUD + 按产品/项目/执行查列表 |
| 反馈 Feedback | | CRUD + close/activate |
| 工单 Ticket | | CRUD + close/activate |
| 应用 System | | CU + 按产品查列表 |
| 用户 User | | CRUD |
| 文件 File | | 编辑名称 + 删除 |
CRUD = 创建(POST) + 读取(GET) + 更新(PUT) + 删除(DELETE);CUD = 无独立全局列表接口
API base path:
$ZENTAO_URL/api.php/v2| Module | Resource Path | Supported Operations |
|---|---|---|
| Program | | CRUD + associated product/project list |
| Product | | CRUD + associated requirements/Bugs/test cases/plans/releases/feedback/tickets/test tasks/applications |
| Project | | CUD + associated executions/requirements/Bugs/test cases/builds/test tasks |
| Execution | | CRUD + associated requirements/tasks/Bugs/test cases/builds/test tasks |
| Story | | CRUD + change/close/activate |
| Epic | | CRUD + change/close/activate |
| Requirement | | CRUD + change/close/activate |
| Bug | | CRUD + resolve/close/activate |
| Task | | CRUD + start/finish/close/activate |
| Testcase | | CRUD |
| Productplan | | CUD + query list by product |
| Build | | CUD + query list by project/execution |
| Release | | CUD + query list by product |
| Testtask | | CUD + query list by product/project/execution |
| Feedback | | CRUD + close/activate |
| Ticket | | CRUD + close/activate |
| System | | CU + query list by product |
| User | | CRUD |
| File | | Edit name + Delete |
CRUD = Create(POST) + Read(GET) + Update(PUT) + Delete(DELETE); CUD = No independent global list interface
分页与筛选
Pagination and Filtering
所有列表接口支持统一的查询参数:
| 参数 | 说明 |
|---|---|
| 筛选状态,如 |
| 排序,格式 |
| 每页数量,最大 1000 |
| 页码,从 1 开始 |
筛选参数名不一致:Program 列表、Execution 全局列表、Task 列表用 ,其余用 。
statusbrowseTypeAll list interfaces support unified query parameters:
| Parameter | Description |
|---|---|
| Filter status, e.g. |
| Sort, format |
| Number of items per page, maximum 1000 |
| Page number, starting from 1 |
Inconsistent filter parameter names: Program list, Execution global list, Task list use , others use .
statusbrowseType常用操作示例
Common Operation Examples
获取进行中的项目及其执行
Get ongoing projects and their executions
bash
curl -s "$ZENTAO_URL/api.php/v2/projects?browseType=doing&recPerPage=100" -H "token: $ZENTAO_TOKEN"
curl -s "$ZENTAO_URL/api.php/v2/projects/{projectID}/executions?browseType=doing" -H "token: $ZENTAO_TOKEN"bash
curl -s "$ZENTAO_URL/api.php/v2/projects?browseType=doing&recPerPage=100" -H "token: $ZENTAO_TOKEN"
curl -s "$ZENTAO_URL/api.php/v2/projects/{projectID}/executions?browseType=doing" -H "token: $ZENTAO_TOKEN"创建需求(必填:productID, title)
Create a requirement (Required: productID, title)
bash
curl -s -X POST "$ZENTAO_URL/api.php/v2/stories" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"productID": 1, "title": "需求标题", "pri": 3, "assignedTo": "admin", "spec": "需求描述"}'bash
curl -s -X POST "$ZENTAO_URL/api.php/v2/stories" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"productID": 1, "title": "Requirement title", "pri": 3, "assignedTo": "admin", "spec": "Requirement description"}'创建 Bug(必填:productID, title, openedBuild)
Create a Bug (Required: productID, title, openedBuild)
bash
curl -s -X POST "$ZENTAO_URL/api.php/v2/bugs" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"productID": 1, "title": "Bug标题", "openedBuild": ["trunk"], "severity": 2, "type": "codeerror"}'bash
curl -s -X POST "$ZENTAO_URL/api.php/v2/bugs" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"productID": 1, "title": "Bug title", "openedBuild": ["trunk"], "severity": 2, "type": "codeerror"}'解决 Bug(必填:resolution)
Resolve a Bug (Required: resolution)
bash
curl -s -X PUT "$ZENTAO_URL/api.php/v2/bugs/{bugID}/resolve" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"resolution": "fixed"}'bash
curl -s -X PUT "$ZENTAO_URL/api.php/v2/bugs/{bugID}/resolve" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"resolution": "fixed"}'创建任务(必填:name, executionID)
Create a task (Required: name, executionID)
bash
curl -s -X POST "$ZENTAO_URL/api.php/v2/tasks" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"executionID": 1, "name": "任务名", "type": "devel", "assignedTo": "admin", "estimate": 4}'bash
curl -s -X POST "$ZENTAO_URL/api.php/v2/tasks" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"executionID": 1, "name": "Task name", "type": "devel", "assignedTo": "admin", "estimate": 4}'完成任务(必填:currentConsumed, realStarted, finishedDate)
Finish a task (Required: currentConsumed, realStarted, finishedDate)
bash
curl -s -X PUT "$ZENTAO_URL/api.php/v2/tasks/{taskID}/finish" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"currentConsumed": 4, "realStarted": "2026-03-25", "finishedDate": "2026-03-25"}'bash
curl -s -X PUT "$ZENTAO_URL/api.php/v2/tasks/{taskID}/finish" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"currentConsumed": 4, "realStarted": "2026-03-25", "finishedDate": "2026-03-25"}'关闭需求(必填:closedReason)
Close a requirement (Required: closedReason)
bash
curl -s -X PUT "$ZENTAO_URL/api.php/v2/stories/{storyID}/close" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"closedReason": "done"}'bash
curl -s -X PUT "$ZENTAO_URL/api.php/v2/stories/{storyID}/close" \
-H "token: $ZENTAO_TOKEN" -H "Content-Type: application/json" \
-d '{"closedReason": "done"}'常用枚举值速查
Common Enumeration Value Quick Reference
| 字段 | 可选值 |
|---|---|
项目模式 | |
Bug 类型 | |
Bug 解决方案 | |
需求关闭原因 | |
需求来源 | |
需求类别 | |
用例类型 | |
测试单类型 | |
发布状态 | |
反馈关闭原因 | |
工单类型 | |
产品类型 | |
产品访问控制 | |
执行类型 | |
| Field | Optional Values |
|---|---|
Project mode | |
Bug type | |
Bug resolution | |
Requirement closing reason | |
Requirement source | |
Requirement category | |
Test case type | |
Test task type | |
Release status | |
Feedback closing reason | |
Ticket type | |
Product type | |
Product access control | |
Execution type | |
意图识别规则
Intent Recognition Rules
| 用户意图关键词 | 对应操作 |
|---|---|
| 进行中的执行/迭代/Sprint | GET /projects?browseType=doing → GET /projects/{id}/executions |
| 获取所有产品/项目/项目集 | GET /products, /projects, /programs |
| 某产品/项目/执行的 Bug | GET /products/{id}/bugs, /projects/{id}/bugs, /executions/{id}/bugs |
| 创建/新增 Bug | POST /bugs(必填:productID, title, openedBuild) |
| 更新/修改 Bug | PUT /bugs/{id} |
| 解决 Bug | PUT /bugs/{id}/resolve(必填:resolution) |
| 关闭 Bug | PUT /bugs/{id}/close |
| 激活 Bug | PUT /bugs/{id}/activate |
| 创建需求 | POST /stories(必填:productID, title) |
| 关闭/激活/变更需求 | PUT /stories/{id}/close, /activate, /change |
| 业务需求 | /epics(同 stories 结构) |
| 用户需求 | /requirements(同 stories 结构) |
| 创建任务 | POST /tasks(必填:name, executionID) |
| 启动任务 | PUT /tasks/{id}/start(必填:realStarted) |
| 完成任务 | PUT /tasks/{id}/finish(必填:currentConsumed, realStarted, finishedDate) |
| 关闭任务 | PUT /tasks/{id}/close |
| 测试用例 | /testcases(CRUD) |
| 测试单 | /testtasks(CUD + 按产品/项目/执行查列表) |
| 产品计划 | /productplans(CUD + 按产品查列表) |
| 版本/Build | /builds(CUD + 按项目/执行查列表) |
| 发布 | /releases(CUD + 按产品查列表) |
| 反馈 | /feedbacks(CRUD + close/activate) |
| 工单 | /tickets(CRUD + close/activate) |
| 应用/系统 | /systems(CU + 按产品查列表) |
| 获取用户列表 | GET /users |
| User intent keywords | Corresponding operation |
|---|---|
| Ongoing execution/iteration/Sprint | GET /projects?browseType=doing → GET /projects/{id}/executions |
| Get all products/projects/programs | GET /products, /projects, /programs |
| Bugs of a product/project/execution | GET /products/{id}/bugs, /projects/{id}/bugs, /executions/{id}/bugs |
| Create/add Bug | POST /bugs (Required: productID, title, openedBuild) |
| Update/modify Bug | PUT /bugs/{id} |
| Resolve Bug | PUT /bugs/{id}/resolve (Required: resolution) |
| Close Bug | PUT /bugs/{id}/close |
| Activate Bug | PUT /bugs/{id}/activate |
| Create requirement | POST /stories (Required: productID, title) |
| Close/activate/change requirement | PUT /stories/{id}/close, /activate, /change |
| Epic | /epics (same structure as stories) |
| Requirement | /requirements (same structure as stories) |
| Create task | POST /tasks (Required: name, executionID) |
| Start task | PUT /tasks/{id}/start (Required: realStarted) |
| Finish task | PUT /tasks/{id}/finish (Required: currentConsumed, realStarted, finishedDate) |
| Close task | PUT /tasks/{id}/close |
| Test case | /testcases (CRUD) |
| Test task | /testtasks (CUD + query list by product/project/execution) |
| Product plan | /productplans (CUD + query list by product) |
| Build | /builds (CUD + query list by project/execution) |
| Release | /releases (CUD + query list by product) |
| Feedback | /feedbacks (CRUD + close/activate) |
| Ticket | /tickets (CRUD + close/activate) |
| Application/system | /systems (CU + query list by product) |
| Get user list | GET /users |
注意事项
Notes
- URL 中的 需替换为实际 ID;不知道 ID 时先调列表接口获取
{id} - PUT 编辑接口:先 GET 详情获取当前完整数据,再将用户修改的字段覆盖进去一并提交
- 状态流转操作 (resolve/close/activate/start/finish/change) 通常有独立的必填字段,不需要先 GET 详情
- 写操作前向用户确认,用户明确要求不确认则直接执行
- 401 响应表示 token 已失效,执行 清除缓存后重新运行
rm ~/.zentao-token.json - 字段名不一致注意:POST builds 用 ,PUT builds 用
executionID;PUT testcases 的模块字段为execution(规范中的拼写)moudule
- in the URL needs to be replaced with the actual ID; if you don't know the ID, call the list interface first to get it
{id} - PUT edit interface: First GET the details to get the current complete data, then overwrite the fields modified by the user and submit together
- Status flow operations (resolve/close/activate/start/finish/change) usually have independent required fields, no need to GET details first
- Confirm with the user before write operations, execute directly if the user explicitly requests no confirmation
- 401 response indicates that the token has expired, execute to clear the cache and run again
rm ~/.zentao-token.json - Note on inconsistent field names: POST builds use , PUT builds use
executionID; the module field of PUT testcases isexecution(spelling in the specification)moudule
完整 API 参考
Complete API Reference
详细的端点列表、必填/可选字段、枚举值和查询参数见 api-reference.md。
For detailed endpoint lists, required/optional fields, enumeration values and query parameters, see api-reference.md.
备用资源
Backup Resources
- 禅道 API 2.0 官方文档:https://www.zentao.net/book/api/2309.html
- 1.0 API 文档(备用):https://www.zentao.net/book/api/1397.html
- ZenTao API 2.0 official documentation: https://www.zentao.net/book/api/2309.html
- 1.0 API documentation (backup): https://www.zentao.net/book/api/1397.html