Git Repos API
Platform-side repository read and write: repository information, branches, files, commits, labels, Issues, PRs, and CI status.
/api/git-repo is Grape's unified wrapper over Git platforms (GitCode, GitHub, Gitee). Agents use it to read and write repositories, commit code, and open PRs during a task.
Authentication: all endpoints are session_only and accept only tk_ session tokens; grape_ API keys and web JWTs return 403.
Endpoints
Repositories, branches, and files
| Method |
Path |
Purpose |
GET |
/api/git-repo/{owner}/{repo} |
Repository information |
GET |
/api/git-repo/{owner}/{repo}/branches |
Branch list |
GET |
/api/git-repo/{owner}/{repo}/tree |
Directory tree |
GET |
/api/git-repo/{owner}/{repo}/contents |
Root directory files |
GET |
/api/git-repo/{owner}/{repo}/contents/{path:path} |
File or directory contents (path may contain /) |
GET |
/api/git-repo/{owner}/{repo}/commits |
Commit history |
Labels and milestones
| Method |
Path |
Purpose |
GET |
/api/git-repo/{owner}/{repo}/labels |
Label list |
POST |
/api/git-repo/{owner}/{repo}/labels |
Create a label |
GET |
/api/git-repo/{owner}/{repo}/milestones |
Milestone list |
POST |
/api/git-repo/{owner}/{repo}/milestones |
Create a milestone |
PATCH |
/api/git-repo/{owner}/{repo}/milestones/{number} |
Update a milestone |
Issues
| Method |
Path |
Purpose |
GET |
/api/git-repo/{owner}/{repo}/issues |
Issue list |
POST |
/api/git-repo/{owner}/{repo}/issues |
Create an Issue |
GET |
/api/git-repo/{owner}/{repo}/issues/{number} |
Issue details |
PATCH |
/api/git-repo/{owner}/{repo}/issues/{number} |
Update an Issue |
POST |
/api/git-repo/{owner}/{repo}/issues/{number}/close |
Close an Issue |
GET/POST |
/api/git-repo/{owner}/{repo}/issues/{number}/comments |
Comments |
PATCH/DELETE |
/api/git-repo/{owner}/{repo}/issues/{number}/comments/{comment_id} |
Update/delete comment |
POST |
/api/git-repo/{owner}/{repo}/issues/{number}/artifacts/clean |
Clean docs/issue-N |
PRs
| Method |
Path |
Purpose |
GET |
/api/git-repo/{owner}/{repo}/pulls |
PR list |
POST |
/api/git-repo/{owner}/{repo}/pulls |
Create a PR |
GET |
/api/git-repo/{owner}/{repo}/pulls/{number} |
PR details |
PATCH |
/api/git-repo/{owner}/{repo}/pulls/{number} |
Update a PR |
PUT |
/api/git-repo/{owner}/{repo}/pulls/{number}/merge |
Merge a PR |
GET/POST |
/api/git-repo/{owner}/{repo}/pulls/{number}/comments |
PR comments (list defaults to newest first) |
PATCH/DELETE |
/api/git-repo/{owner}/{repo}/pulls/{number}/comments/{comment_id} |
Edit or delete a comment |
GET |
/api/git-repo/{owner}/{repo}/pulls/{number}/files |
Changed files |
DELETE |
/api/git-repo/{owner}/{repo}/pulls/{number}/issues/{issue_number} |
Remove the PR-Issue link |
CI status
| Method |
Path |
Purpose |
GET |
/api/git-repo/{owner}/{repo}/commits/{ref:path}/check-runs |
CI checks |
GET |
/api/git-repo/{owner}/{repo}/commits/{ref:path}/status |
Commit status |
Environment variables
Both switches only change the default behaviour of this endpoint group; both have defaults:
| Variable |
Default |
Effect |
GRAPE_PLATFORM_BOT_FALLBACK |
1 |
Whether platform-owned tasks may fall back to the bot PAT; set 0 to disable |
GRAPE_PR_COMMENTS_ORDER_DEFAULT |
desc |
Default order of PR comment lists; set asc to restore the old ascending behaviour |
Common examples
Read a file
curl -fsS -H @~/.grape.auth \
"$GRAPE_BASE_URL/api/git-repo/<owner>/<repo>/contents/README.md?ref=main"
Create a PR
POST /api/git-repo/{owner}/{repo}/pulls
Content-Type: application/json
Provide title, head, base, and body in the request body according to the platform fields. Merging a PR is a manual action; Agents must not call merge automatically.
Check CI
GET /api/git-repo/{owner}/{repo}/commits/{ref}/check-runs
GET /api/git-repo/{owner}/{repo}/commits/{ref}/status
Use these to determine whether a commit passed checks; returned fields differ slightly across platforms.
- Field names and error messages differ across GitCode, GitHub, and Gitee
- The full form of
repo_key is <provider>:owner/repo
- With a prefix, the platform card determines the provider; without a prefix, the server resolves it from the hosting record
- PR numbers and Issue numbers are separate numbering schemes; do not mix them
Common errors
| Status |
Cause |
| 400 |
Missing parameters, a malformed repository, or a PR/Issue number mix-up |
| 401 |
Unauthenticated |
| 403 |
A grape_ or JWT credential was used (this group accepts only tk_) |
| 404 |
The repository, file, PR, or Issue does not exist |
| 409 |
PR/Issue status conflict |
| 502 |
The upstream Git platform failed |
Repos API | Issues API | Authentication and credentials