Create a commit comment¶
POST /api/v5/repos/{owner}/{repo}/commits/{sha}/comments
This endpoint creates a comment on a specific commit in the specified repository. You must provide the namespace that owns the repository, the repository path, and the commit ID, along with the comment content. On success, it returns basic information such as the comment ID, content, and creation and update times.
Access token support¶
- AtomGit user access tokens
Anonymous access¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Address path of the namespace that owns the repository (address path of the organization or user) |
repo |
path | string | Yes | Repository path (path) |
sha |
path | string | Yes | Commit ID |
access_token |
query | string | Yes | User authorization code |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"body": {
"description": "Comment content",
"type": "string"
}
},
"required": ["body"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
string | Yes | No | Comment ID |
body |
string | Yes | No | Comment content |
created_at |
string | Yes | No | Creation time |
updated_at |
string | Yes | No | Update time |
Error response¶
A
200/success response alone is not enough: callers need to know what a failure looks like in order to write error handling.
400 Parameter error
401 Unauthenticated
The actual error field names are those returned by the backend; the examples above are for reference only.
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Bad request |
401 |
Authentication required |
403 |
Forbidden |
404 |
Resource not found |
500 |
Internal server error |
Request example¶
Parameter description¶
Replace the placeholders in the example with actual values: <owner> is the address path of the namespace that owns the repository (address path of the organization or user); <repo> is the repository path (path); <sha> is the commit ID; <token> is your AtomGit user access token; <body> is the comment content.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits/<sha>/comments?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"body": "Comment content"}'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits/<sha>/comments?access_token=<token>",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({ body: "Comment content" }),
}
);
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.post(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits/<sha>/comments?access_token=<token>",
headers={
"Content-Type": "application/json",
"Accept": "application/json",
},
json={"body": "Comment content"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"id": "12312sadsa",
"body": "content",
"created_at": "2024-03-28T11:19:33+08:00",
"updated_at": "2024-03-28T11:19:33+08:00"
}
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
400 |
Parameter error or the request cannot be parsed |
404 |
The requested path does not exist |
405 |
Request method not supported |
429 |
Too many requests; rate limit triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc