Skip to content

Create repository discussion comment

POST /api/v5/repos/{owner}/{repo}/discuss/{number}/comment

This endpoint creates a comment under a discussion in the specified repository. It accepts the comment content in Markdown format and returns the newly created comment along with its author, discussion association, and other details.

Access token support

  • AtomGit user access token (AtomGit user access tokens)

Anonymous access

This endpoint does not allow anonymous access

Request parameters

Parameter Location Type Required Description
owner path string Yes Namespace path of the repository (the path of an enterprise, organization, or personal address)
repo path string Yes Repository path (path)
number path string Yes Discussion number
access_token query string Yes User authorization code

Request Body:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "md_content": {
      "description": "Comment content (markdown)",
      "type": "string"
    }
  },
  "required": ["md_content"]
}

Response parameters

Field Type Always returned Nullable Description
id string Yes — Comment ID
created_at string Yes — Creation time
updated_at string Yes — Update time
author object Yes — Comment author information
discuss_id string Yes — Discussion ID
content string Yes — Comment content (plain text)
md_content string Yes — Comment content (markdown)
parent_id string Yes — Parent comment ID
type integer Yes — Comment type, 1: comment, 2: reply
is_hide integer Yes — Whether hidden
reply_total integer Yes — Reply total
like_total integer Yes — Like total
is_like boolean Yes — Whether the current user has liked
is_deleted integer Yes — Whether deleted
is_remark integer Yes — Whether flagged

author object

Field Type Always returned Nullable Description
author.avatar_url string Yes — Avatar URL
author.id string Yes — User ID
author.object_id string Yes — Object ID
author.login string Yes — Login name
author.name string Yes — User name

Error response

400 Parameter error

{
  "error": "invalid_request",
  "message": "Parameter md_content cannot be empty",
  "field": "md_content"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

Error field names follow what the backend actually returns.

HTTP response status codes

Status code Description
200 Success (OK)
304 Not modified
401 Authentication required (Requires authentication)
403 Access forbidden (Forbidden)

Request example

Parameter description

replace <owner> with the namespace path of the repository (the path of an enterprise, organization, or personal address); replace <repo> with the repository path (path); replace <number> with the discussion number; replace <token> with your AtomGit user access token.

cURL

curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/discuss/<number>/comment?access_token=<token>' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"md_content": "This is the comment content"}'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch(
  "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/discuss/<number>/comment?access_token=<token>",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    body: JSON.stringify({
      md_content: "This is the 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>/discuss/<number>/comment",
    params={"access_token": "<token>"},
    json={"md_content": "This is the comment content"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": "c_12345",
  "created_at": "2026-10-14T10:00:00+08:00",
  "updated_at": "2026-10-14T10:00:00+08:00",
  "author": {
    "avatar_url": "https://api.atomgit.com/avatar.png",
    "id": "u_1001",
    "object_id": "1001",
    "login": "octocat",
    "name": "octocat"
  },
  "discuss_id": "d_6789",
  "content": "This is the comment content",
  "md_content": "This is the comment content",
  "parent_id": "",
  "type": 1,
  "is_hide": 0,
  "reply_total": 0,
  "like_total": 0,
  "is_like": false,
  "is_deleted": 0,
  "is_remark": 0
}

Error codes

Error code Description
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
400 Parameter error or unparsable request
404 Request path does not exist
405 Method not supported
429 Too many requests; rate limit triggered
500 Internal server error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc