Bugbot 评审与管理 API
异步触发评审、读取 dry-run findings,并分开使用管理端点的认证。
This page has not been translated into English yet. The original Chinese version is shown below.
Bugbot review/analytics API 对 Enterprise 提供。评审提交后异步运行,保存 request_id 以匹配后续 analytics;排队成功不代表评审完成。
触发评审
POST /bugbot/review 用 Basic,要求 admin:* scope,每团队每分钟 30 次。prUrl 必填,官方要求 GitHub PR 或 GitLab MR 完整 URL。
curl --request POST https://api.cursor.com/bugbot/review \
-u YOUR_API_KEY: \
--header 'Content-Type: application/json' \
--data '{"prUrl":"https://github.com/your-org/your-repo/pull/42","dryRun":true}'dryRun 默认 false;true 时运行完整分析且保存 findings、正常计费,但不向 SCM 发布评论、checks 或其他副作用。dry-run 还受每团队每分钟 10 次额外限制。无法评审时返回 400 并说明例如仓库禁用。
获取结果
GET /analytics/team/bugbot-reviews 要求 read:* scope,使用 Basic。startDate 默认 7 天前、endDate 默认现在;repo 用 host/owner/repo,可按 prNumber/dryRun 过滤,page 默认 1,pageSize 默认 100、最大 250。
查找与 trigger request_id 相同的记录,analytics 可能稍后出现。posted findings 用 comment_id/resolution_status,dry-run 用 title/description/locations,前两字段为 null。cost_cents 等字段也可能 null,不能把缺失值当作 0。
管理配置是另一组接口
Bugbot Admin Configuration API 文档要求 team Admin API Key 通过 Bearer 传入,每团队每分钟 60 次,与 review/analytics 的 Basic 不同。API 总览笼统写 Bugbot 使用 Basic,这里按具体端点章节说明。
| 方法与路径 | 参数及用途 |
|---|---|
POST /bugbot/repo/update | repoUrl、enabled 必填,可选 manualTriggerOnly |
GET /bugbot/repos | 列出团队仓库的启用、manual-only 和时间戳 |
POST /bugbot/user/update | username、allow 必填,调整用户访问 |
manualTriggerOnly 为 true 时不自动评审 push,评论触发仍取决于服务商支持。UI 有缓存,API 响应反映数据库当前状态。
用户 allow/block 模式
调用 user/update 前须在团队 Bugbot settings 启用 Only(allowlist)或 Everyone but(blocklist),否则报错。allow 为 true:allowlist 加入、blocklist 移除;false 则相反。
username 是 GitHub/GitLab/Bitbucket 用户名,大小写不敏感并规范化小写。列表在团队级存储并跨其安装生效,不能把该 username 字段推广为 Azure 的登录邮箱筛选 API。