代码托管 API

连接 Gitea 或 GitHub 的 Webhook 和推送记录,以及任务关联的 PR 和提交。

由群历 REST API 的 OpenAPI 契约(openapi/qunli-api.yaml,qunli-api 提交 b127eb8)生成。路径都相对于 https://qunli.co;认证见认证,响应包装、分页和错误格式见约定。字段说明是契约里的英文原文。

代码托管

GET/api/v1/accounts/{account_id}/git_connections

List the team's code-hosting connections (Gitea / GitHub webhooks)

Active human team owners/admins only (agents and other members 403): every connection carries its webhook signing secret. Paste webhook_url and secret into an organization (or repository) webhook on the code host, content type application/json, events push and pull_request. Qunli never calls the code host — it only receives webhooks — so a code host inside a private network works as long as it can reach qunli.co.

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。

响应

状态说明返回
200Connections, oldest firstdata: GitConnection[]
403Authenticated but not permitted.ProblemDetails

POST/api/v1/accounts/{account_id}/git_connections

Connect a Gitea or GitHub organization

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。

请求体application/json,必填

字段类型必填说明
git_connectionobject是
git_connection.providergitea | github是
git_connection.namestring是

响应

状态说明返回
201The connection with its webhook URL and secretdata: GitConnection
400Malformed request or invalid parameter.ProblemDetails
403Authenticated but not permitted.ProblemDetails
422Validation failed.ProblemDetails

GET/api/v1/accounts/{account_id}/git_connections/{id}

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
id路径string (uuid)是

响应

状态说明返回
200The connectiondata: GitConnection
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails

PUT/api/v1/accounts/{account_id}/git_connections/{id}

Same as PATCH

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
id路径string (uuid)是

请求体application/json,必填

字段类型必填说明
git_connectionobject是
git_connection.namestring否
git_connection.statusactive | disabled否

响应

状态说明返回
200The updated connectiondata: GitConnection
400Malformed request or invalid parameter.ProblemDetails
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails
422Validation failed.ProblemDetails

PATCH/api/v1/accounts/{account_id}/git_connections/{id}

Rename, disable or re-enable a connection

A disabled connection answers its webhooks with 404 and keeps the code already linked to tasks.

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
id路径string (uuid)是

请求体application/json,必填

字段类型必填说明
git_connectionobject是
git_connection.namestring否
git_connection.statusactive | disabled否

响应

状态说明返回
200The updated connectiondata: GitConnection
400Malformed request or invalid parameter.ProblemDetails
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails
422Validation failed.ProblemDetails

DELETE/api/v1/accounts/{account_id}/git_connections/{id}

Remove a connection and the code it linked to tasks

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
id路径string (uuid)是

响应

状态说明返回
200Removed (`{ "data": null }`).data: null
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails

POST/api/v1/accounts/{account_id}/git_connections/{git_connection_id}/secret

Issue a new webhook signing secret

Deliveries signed with the previous secret get 401 from now on; update the code host's webhook right away.

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
git_connection_id路径string (uuid)是

响应

状态说明返回
201The connection with its new secretdata: GitConnection
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails

GET/api/v1/accounts/{account_id}/git_connections/{git_connection_id}/deliveries

Recent webhook deliveries of a connection, newest first

Kept 14 days. Only deliveries with a valid signature for a tracked event (push, pull_request) are listed.

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
git_connection_id路径string (uuid)是
page查询integer否默认 1
limit查询integer否Clamped to 1–100 (default 30).

响应

状态说明返回
200Delivery pagedata: GitDelivery[] · meta: PaginationMeta
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails

GET/api/v1/accounts/{account_id}/recordings/{recording_id}/code_references

Pull requests and commits linked to a task

A pull request is linked when its title or description names the task: its canonical URL (https://qunli.co/<account>/T1042, this team only) or its bare ref ("T1042", "#T1042"; uppercase T and at least three digits, resolved in the connection's team). Its head branch's commits follow it (including commits pushed before it was opened, up to 30 days back); a commit whose own message names the task is linked directly. Pull requests come first (newest opened first), then commits (newest first). Empty for anything without linked code. Guests get 403; trashed recordings and others' drafts 404.

参数

参数位置类型必填说明
account_id路径string是团队的数字 id,和网页地址里的相同,例如 2025。
recording_id路径string (ref)是引用号,例如 T1042,大小写不敏感,可带前导 #。
page查询integer否默认 1
limit查询integer否Clamped to 1–200 (default 100).

响应

状态说明返回
200Linked code pagedata: CodeReference[] · meta: PaginationMeta
401Missing or invalid authentication.ProblemDetails
403Authenticated but not permitted.ProblemDetails
404Resource does not exist or has been trashed.ProblemDetails

数据结构

上面的响应用到的对象。字段的类型是另一个对象时,它也列在这里。

GitConnection

字段类型必填说明
idstring (uuid)是
providergitea | github是
namestring是
statusactive | disabled是
webhook_urlstring是Payload URL to paste into the code host's webhook.
secretstring是Webhook secret (HMAC-SHA256 signing key) to paste alongside webhook_url.
eventsstring[]是Events to enable on the code host (push, pull_request).
last_delivery_atstring (date-time) | null是Last delivery with a valid signature.
last_eventstring | null是
last_errorstring | null是Last unreadable payload, if any.
last_error_atstring (date-time) | null是
creatorUserRef是
created_atstring (date-time)是
updated_atstring (date-time)是

GitDelivery

字段类型必填说明
idstring (uuid)是
delivery_idstring是The code host's delivery id.
eventpush | pull_request是
statuspending | processed | ignored | failed是
errorstring | null是
created_atstring (date-time)是
processed_atstring (date-time) | null是

PaginationMeta

字段类型必填说明
pageinteger是
limitinteger是
totalinteger是
total_pagesinteger是
has_nextboolean是

CodeReference

A pull request (kind pull_request: number … closed_at set, commit fields null) or a commit (kind commit: sha … committed_at set, pull request fields null) linked to a task.

字段类型必填说明
idstring (uuid)是
kindpull_request | commit是
git_connectionGitConnectionRef是
repositorystring是Full name, "org/repo".
urlstring | null是On the code host; may be reachable only inside the team's network.
author_loginstring | null是
numberinteger | null否
titlestring | null否
stateopen | closed | merged | null否
draftboolean | null否
head_branchstring | null否
base_branchstring | null否
merge_commit_shastring | null否
opened_atstring (date-time) | null否
merged_atstring (date-time) | null否
closed_atstring (date-time) | null否
shastring | null否
messagestring | null否
branchstring | null否Branch the commit was first pushed to.
author_namestring | null否
committed_atstring (date-time) | null否
pull_request_numberinteger | null否The linked pull request that brought this commit; null when its own message links the task.
created_atstring (date-time)是

UserRef

字段类型必填说明
idstring (uuid)是User UUID.
public_idstring | null是Member ref ("U12") in this account.
namestring | null是
avatar_urlstring | null是
kindhuman | agent | app | null是null only for an unknown (deleted) user; app is an integration's identity (a code-hosting connection), never a team member.

GitConnectionRef

字段类型必填说明
idstring (uuid)是
providergitea | github是
namestring是